ASPxClientRichEdit.FloatingObjectMoved Event

Fires after a floating object has been moved and allows you to change the object’s new position.

Declaration

FloatingObjectMoved: ASPxClientEvent<ASPxClientRichEditFloatingObjectMovedEventHandler>

Event Data

The FloatingObjectMoved event's data class is ASPxClientRichEditFloatingObjectMovedEventArgs. The following properties provide information specific to this event:

Property Description
newPosition The floating object’s new position.
objectX The x-coordinate (in pixels) of the upper-left corner of the floating object relative to the page.
objectY The y-coordinate (in pixels) of the upper-left corner of the floating object relative to the page.
pageIndex Returns an index of a page where a floating object has been moved.
pageIntervals Returns an array of intervals that are belongs to the current page (pageIndex).
subDocumentId Returns the active sub-document’s identifier.

Remarks

The code sample below demonstrates how to change a position of a floating object if is has been moved inside a field result.

function FloatingObjectMoved(s, e) {
    var subDoc = s.document.subDocuments[e.subDocumentId];
    var pos = e.newPosition;
    var fields = subDoc.findFields(pos);
    if (fields.length > 0) {
        var posInsideCurrentPage = function (pos) {
            for (var i = 0, pi; pi = e.pageIntervals[i]; i++) {
                if (pos >= pi.start && pos < pi.start + pi.length)
                    return true;
            }
            return false;
        };
        var fieldInterval = fields[0].interval;
        var fieldStart = fieldInterval.start;
        if (pos > fieldStart) {
            if (posInsideCurrentPage(fieldStart)) {
                e.newPosition = fieldStart;
            }
            else {
                var fieldEnd = fieldInterval.start + fieldInterval.length;
                if (posInsideCurrentPage(fieldEnd)) {
                    e.newPosition = fieldEnd;
                }
                else {
                    // if it is impossible to move the floating object outside a field and on the current page (e.g. if the field occupies the entire page)
                    e.newPosition = fieldStart;
                    e.objectX = 200;
                    e.objectY = 200;
                }
            }
        }
    }
}
  <dx:ASPxRichEdit ID="DemoRichEdit" runat="server" ActiveTabIndex="0" ShowConfirmOnLosingChanges="false">
      <ClientSideEvents FloatingObjectMoved="FloatingObjectMoved" />
  </dx:ASPxRichEdit>

Refer to the following section for more information about client-side events: Client API.

See Also