Class DragController
Represents a DragController that helps to move (drag) the selected objects in a diagram.
Inherited Members
Namespace: Syncfusion.Blazor.Diagram
Assembly: Syncfusion.Blazor.dll
Syntax
public class DragController : InteractionControllerBase
Remarks
The DragController handles interactive dragging operations on diagram elements, managing mouse events and object movement while maintaining proper state management.
This controller manages the complete drag lifecycle (start, move, end) and integrates with the diagram's command system for undo/redo support.
Constructors
DragController(SfDiagramComponent)
Initializes a new instance of the DragController class with the specified SfDiagramComponent.
Declaration
public DragController(SfDiagramComponent diagram)
Parameters
Type | Name | Description |
---|---|---|
SfDiagramComponent | diagram | The SfDiagramComponent instance that this controller will manage drag operations for. This parameter cannot be null and must be a valid diagram component. |
Remarks
This constructor establishes the drag controller for the specified diagram component, enabling drag-and-drop functionality.
Methods
OnMouseDown(DiagramMouseEventArgs)
Handles the mouse down event when the mouse pointer is moved over the element and a mouse button is clicked during drag operations.
Declaration
public override void OnMouseDown(DiagramMouseEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
DiagramMouseEventArgs | args | A DiagramMouseEventArgs containing information about the mouse event, including position coordinates, button state, and target element details. |
Overrides
Remarks
This method initiates drag behavior when a mouse button is pressed. Override to customize drag initiation or add validation logic.
OnMouseLeave(DiagramMouseEventArgs)
Handles the mouse pointer leaving the draggable element during a drag operation.
Declaration
public override void OnMouseLeave(DiagramMouseEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
DiagramMouseEventArgs | args | A DiagramMouseEventArgs containing information about the mouse event, including position coordinates and element references. |
Overrides
Remarks
Automatically invoked when the mouse pointer exits the element boundaries during drag operations. Calls OnMouseUp(DiagramMouseEventArgs) to clean up the drag operation and avoid incomplete drag states.
OnMouseMove(DiagramMouseEventArgs)
Handles mouse movement events during drag operations for the DragController.
Declaration
public override bool OnMouseMove(DiagramMouseEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
DiagramMouseEventArgs | args | A DiagramMouseEventArgs containing information about the mouse event, including position coordinates and mouse state. |
Returns
Type | Description |
---|---|
System.Boolean | A System.Boolean value indicating whether the mouse move event was handled. Returns true if the event is processed and should be blocked from further propagation; otherwise, false. |
Overrides
Remarks
Called continuously during drag operations to track mouse position and update drag behavior. Override to implement custom drag logic or visual feedback.
OnMouseUp(DiagramMouseEventArgs)
Handles the mouse button release event during drag operations on diagram elements.
Declaration
public override void OnMouseUp(DiagramMouseEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
DiagramMouseEventArgs | args | A DiagramMouseEventArgs containing information about the mouse event, including position, button state, and target element. Can be null if no event data is available. |
Overrides
Remarks
Called when a mouse button is released over a diagram element, typically ending a drag operation. Override to implement custom drag completion logic or finalize element positioning.