Class InteractionControllerBase
Represents the base class for interactive tools in diagram components, providing foundational functionality for handling user interactions.
Inheritance
Namespace: Syncfusion.Blazor.Diagram
Assembly: Syncfusion.Blazor.dll
Syntax
public class InteractionControllerBase : CommonController
Remarks
The InteractionControllerBase class serves as the foundation for all interactive controllers in the diagram framework, inheriting from CommonController to provide virtual methods for customizing interaction behaviors.
This class handles common interaction patterns including mouse events, drag operations. It integrates with the diagram's event system to ensure consistent interaction behavior across diagram elements.
Constructors
InteractionControllerBase(SfDiagramComponent)
Initializes a new instance of the InteractionControllerBase class with the specified diagram component.
Declaration
public InteractionControllerBase(SfDiagramComponent diagram)
Parameters
Type | Name | Description |
---|---|---|
SfDiagramComponent | diagram | The SfDiagramComponent instance that this controller will interact with. This parameter provides access to the diagram's command handler and other essential diagram services. |
Remarks
This constructor establishes the connection between the interaction controller and the diagram component by setting up the Syncfusion.Blazor.Diagram.InteractionControllerBase.CommandHandler property. If the diagram parameter is null, the Syncfusion.Blazor.Diagram.InteractionControllerBase.CommandHandler will remain uninitialized.
Properties
CurrentPosition
Gets or sets the current position of the element.
Declaration
protected DiagramPoint CurrentPosition { get; set; }
Property Value
Type |
---|
DiagramPoint |
InAction
Allows to decide whether an element in action or not.
Declaration
protected bool InAction { get; set; }
Property Value
Type |
---|
System.Boolean |
PreviousPosition
Gets or sets the previous position of the element.
Declaration
protected DiagramPoint PreviousPosition { get; set; }
Property Value
Type |
---|
DiagramPoint |
StartPosition
Gets or sets the starting point of the element.
Declaration
protected DiagramPoint StartPosition { get; set; }
Property Value
Type |
---|
DiagramPoint |
Methods
OnMouseDown(DiagramMouseEventArgs)
Handles the mouse down event when the mouse pointer is moved over an element and a mouse button is clicked.
Declaration
public override void OnMouseDown(DiagramMouseEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
DiagramMouseEventArgs | args | A DiagramMouseEventArgs containing information about the mouse event, including the target element and cursor position. If null, the method returns without performing any action. |
Overrides
Remarks
Initializes interaction state by capturing the current element and position, triggers the start action, and enables tooltip visibility for subsequent mouse interaction handling.
OnMouseLeave(DiagramMouseEventArgs)
Handles the mouse pointer leaving the diagram element by cleaning up the current interaction.
Declaration
public override void OnMouseLeave(DiagramMouseEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
DiagramMouseEventArgs | args | A DiagramMouseEventArgs containing the mouse event data including position coordinates and element information. Cannot be null. |
Overrides
Remarks
This method delegates to OnMouseUp(DiagramMouseEventArgs) to ensure proper cleanup of ongoing interactions and prevent incomplete interaction states.
OnMouseMove(DiagramMouseEventArgs)
Handles mouse pointer movement over diagram elements and updates the current interaction state.
Declaration
public override bool OnMouseMove(DiagramMouseEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
DiagramMouseEventArgs | args | A DiagramMouseEventArgs containing the mouse event data including position information. If null, the method will skip position updates but still return the blocked state. |
Returns
Type | Description |
---|---|
System.Boolean | A System.Boolean indicating whether the mouse move event should be processed further. Returns true when the interaction is not blocked, false when blocked. |
Overrides
Remarks
Closes any open context menus and updates the CurrentPosition with mouse coordinates. Returns the inverse of the blocked
field to indicate whether further processing should continue.
OnMouseUp(DiagramMouseEventArgs)
Handles the mouse button release event when the mouse pointer is moved over a diagram element.
Declaration
public override void OnMouseUp(DiagramMouseEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
DiagramMouseEventArgs | args | A DiagramMouseEventArgs containing information about the mouse event, including position coordinates and button state. Can be null. |
Overrides
Remarks
This method updates the current mouse position, hides tooltips, and finalizes the interaction through Syncfusion.Blazor.Diagram.InteractionControllerBase.EndAction when valid args
are provided.
Called automatically as part of the mouse interaction lifecycle to clean up the interaction state after mouse button release.