/// <summary> /// Called when an element is being dragged. This will clear the DragElement /// </summary> /// <param name="position"></param> public void dragging(IntVector2 position) { if (allowDragging) { if (firstDrag) { rmlComponent.cancelAndHideEditor(); firstDrag = false; } dragIconPreview.setPosition(position.x - (dragIconPreview.Width / 2), position.y - (int)(dragIconPreview.Height * .75f)); if (!dragIconPreview.Visible && (Math.Abs(dragMouseStartPosition.x - position.x) > 5 || Math.Abs(dragMouseStartPosition.y - position.y) > 5)) { dragIconPreview.Visible = true; dragIconPreview.setItemResource(iconName); LayerManager.Instance.upLayerItem(dragIconPreview); } if (IsDragging) { if (dragElement != null) { IntVector2 localCoord = rmlComponent.localCoord(position); if (localCoord.x < dragElement.AbsoluteLeft || localCoord.y < dragElement.AbsoluteTop || localCoord.x > dragElement.OffsetWidth + dragElement.AbsoluteLeft || localCoord.y > dragElement.OffsetHeight + dragElement.AbsoluteTop) { insertRml = dragElement.ElementRml; undoRml = rmlComponent.UnformattedRml; rmlComponent.setPreviewElement(position, insertRml, "div"); Element parent = dragElement.ParentNode; if (parent != null) { parent.RemoveChild(dragElement); } dragElement = null; } } else { if (!rmlComponent.setPreviewElement(position, insertRml, "div")) { offDocument = true; if (ElementDraggedOffDocument != null) { ElementDraggedOffDocument.Invoke(rmlComponent, position, insertRml, "div"); } } else if (offDocument) { offDocument = false; if (ElementReturnedToDocument != null) { ElementReturnedToDocument.Invoke(rmlComponent, position, insertRml, "div"); } } } } } }