Class MouseControllerDispatcher
MouseControllerDispatcher has no dependency on ScrollControl. You can use it with any FrameworkElement-derived class. You only need to forward mouse events to methods from IMouseEventsTarget interface or add MouseControllerDispatcher to MouseEventTargetCollection.
VirtualizingCellsControl uses a derived CellMouseControllerDispatcher class which adds support for changing context of a mouse operation when pressing mouse inside a textbox or other UIElement and then switching to a cell selection mode when moving mouse outside textbox.
Inheritance
Inherited Members
Namespace: Syncfusion.Windows.Controls.Scroll
Assembly: Syncfusion.GridCommon.WPF.dll
Syntax
public class MouseControllerDispatcher : NonFinalizeDisposable, IDisposable, IEnumerable, IMouseEventsTarget
Constructors
MouseControllerDispatcher(FrameworkElement)
Initializes a new MouseControllerDispatcher object and associates it with the parent control.
Declaration
public MouseControllerDispatcher(FrameworkElement owner)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.FrameworkElement | owner |
Fields
CanHandleMouseDown
Declaration
public bool CanHandleMouseDown
Field Value
Type |
---|
System.Boolean |
Properties
ActiveController
Returns a reference to the active mouse controller that is receiving MouseDown, MouseMove and MouseUp messages when the user has pressed a mouse button.
Declaration
public IMouseController ActiveController { get; set; }
Property Value
Type |
---|
IMouseController |
CancelCaptureInfo
Gets the cancel capture info.
Declaration
public ICaptureContext CancelCaptureInfo { get; }
Property Value
Type | Description |
---|---|
ICaptureContext | The cancel capture info. |
Cursor
Returns the cursor to be displayed.
Declaration
public Cursor Cursor { get; }
Property Value
Type |
---|
System.Windows.Input.Cursor |
IgnoreMouse
Gets a value indicating whether mouse events should be ignored.
Declaration
public bool IgnoreMouse { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
InCancelMode
Gets a value indicating whether instance is in CancelMode.
Declaration
public bool InCancelMode { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
InMouseDown
Gets a value indicating whether instance is in MouseDown.
Declaration
public bool InMouseDown { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
InMouseMove
Gets a value indicating whether instance is in MouseMove.
Declaration
public bool InMouseMove { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
InMouseUp
Gets a value indicating whether instance is in MouseUp.
Declaration
public bool InMouseUp { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
IsCaptureCanceled
Gets a value indicating whether this instance is mouse captured by child element.
Declaration
public bool IsCaptureCanceled { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
IsMouseCapturedByChildElement
Gets a value indicating whether this instance is mouse captured by child element.
Declaration
public virtual bool IsMouseCapturedByChildElement { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
IsMouseHovering
Gets a value indicating whether this instance is mouse hovering.
Declaration
public virtual bool IsMouseHovering { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
IsMouseTracking
Gets a value indicating whether the mouse tracking feature is enabled.
Declaration
public bool IsMouseTracking { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
LastHitTestCode
Returns the last HitTest value returned that was non-zero. Check this property if you need to make decision on your mouse controller's HitTest.
Declaration
public int LastHitTestCode { get; }
Property Value
Type |
---|
System.Int32 |
MouseDownLocation
Gets the mouse down location.
Declaration
public Point MouseDownLocation { get; }
Property Value
Type | Description |
---|---|
System.Windows.Point | The mouse down location. |
MouseDownTick
Gets the mouse down tick (Environment.TickCount at mouse down).
Declaration
public int MouseDownTick { get; }
Property Value
Type | Description |
---|---|
System.Int32 | The mouse down tick. |
MouseHoverController
Returns the controller that currently receives mouse hovering messages.
Declaration
protected IMouseController MouseHoverController { get; }
Property Value
Type |
---|
IMouseController |
OverrideMouseCursor
Declaration
public bool OverrideMouseCursor { get; set; }
Property Value
Type |
---|
System.Boolean |
Owner
Returns a reference to the associated control.
Declaration
public FrameworkElement Owner { get; }
Property Value
Type |
---|
System.Windows.FrameworkElement |
TrackMouse
Enables support for mouse tracking.
Declaration
public Rect TrackMouse { get; set; }
Property Value
Type |
---|
System.Windows.Rect |
Remarks
Specify the bounds where the mouse tracking should start. As soon as the user moves the mouse
over the specified region, MouseControllerDispatcher will simulate a mouse down event. When the user presses
any mouse button MouseControllerDispatcher will simulate a mouse up and resets the mouse tracking mode. After
the inital click on a mouse button, mouse processing will work as usual.
note
Mouse tracking lets you easily simulate the behavior of windows combo boxes.
Methods
Add(IMouseController)
Registers a mouse controller.
Declaration
public void Add(IMouseController controller)
Parameters
Type | Name | Description |
---|---|---|
IMouseController | controller |
CancelMode()
Cancel any mouse processing.
Declaration
public void CancelMode()
Clear()
Declaration
public void Clear()
Contains(IMouseController)
Indicates whether a mouse controller has previously been registered.
Declaration
public bool Contains(IMouseController controller)
Parameters
Type | Name | Description |
---|---|---|
IMouseController | controller |
Returns
Type |
---|
System.Boolean |
CreateCaptureInfo(Point)
Creates the capture info when the mouse is pressed inside a child UIElement.
Declaration
protected virtual ICaptureContext CreateCaptureInfo(Point point)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.Point | point | The point. |
Returns
Type |
---|
ICaptureContext |
CreateSuspendState()
Creates the suspend state when CancelMode() was called.
Declaration
protected virtual MouseControllerDispatcher.SuspendState CreateSuspendState()
Returns
Type |
---|
MouseControllerDispatcher.SuspendState |
Dispose(Boolean)
Resets the dispatcher and calls Dispose for any registered mouse controller and unregisters all mouse controllers.
Declaration
protected override void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | disposing |
Overrides
Find(String)
Searchs a mouse controller by comparing with the name returned from IMouseController.Name.
Declaration
public IMouseController Find(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name |
Returns
Type |
---|
IMouseController |
HitTest(MouseControllerEventArgs, out IMouseController)
HitTest loops through all controllers and call HitTest on each of them. Only one mouse controller can get voted to receive mouse messages.
Declaration
public int HitTest(MouseControllerEventArgs mouseEventArgs, out IMouseController controller)
Parameters
Type | Name | Description |
---|---|---|
MouseControllerEventArgs | mouseEventArgs | The MouseControllerEventArgs instance containing the event data. |
IMouseController | controller | The controller. |
Returns
Type | Description |
---|---|
System.Int32 | The result identifying the hit-test context. |
HitTest(Point)
HitTest loops through all controllers and call HitTest on each of them. Only one mouse controller can get voted to receive mouse messages.
Declaration
public int HitTest(Point point)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.Point | point | The point in client coordinates to be hit tested. |
Returns
Type | Description |
---|---|
System.Int32 | The result identifying the hit-test context. |
Remarks
The current result of the vote gets passed to the next mouse controller. If a controller wants to handle mouse events, it can decide based on the existing vote if it has higher priority for it to handle mouse messages than the existing vote.
HitTest(Point, Nullable<MouseButton>, Int32, out IMouseController)
HitTest loops through all controllers and call HitTest on each of them. Only one mouse controller can get voted to receive mouse messages.
Declaration
public int HitTest(Point point, Nullable<MouseButton> mouseButton, int clicks, out IMouseController controller)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.Point | point | The point in client coordinates to be hit tested. |
System.Nullable<System.Windows.Input.MouseButton> | mouseButton | The mouse button that is pressed. |
System.Int32 | clicks | 1 for single-click; 2 for double click. |
IMouseController | controller | A placeholder where a reference to the winning IMouseController is returned. |
Returns
Type | Description |
---|---|
System.Int32 | The result identifying the hit-test context. |
HitTest(Point, MouseButton)
HitTest loops through all controllers and call HitTest on each of them. Only one mouse controller can get voted to receive mouse messages.
Declaration
public int HitTest(Point point, MouseButton mouseButton)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.Point | point | The point in client coordinates to be hit tested. |
System.Windows.Input.MouseButton | mouseButton | The mouse button that is pressed. |
Returns
Type | Description |
---|---|
System.Int32 | The result identifying the hit-test context. |
HitTest(Point, MouseButton, out IMouseController)
HitTest loops through all controllers and call HitTest on each of them. Only one mouse controller can get voted to receive mouse messages.
Declaration
public int HitTest(Point point, MouseButton mouseButton, out IMouseController controller)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.Point | point | The point in client coordinates to be hit tested. |
System.Windows.Input.MouseButton | mouseButton | The mouse button that is pressed. |
IMouseController | controller | A placeholder where a reference to the winning IMouseController is returned. |
Returns
Type | Description |
---|---|
System.Int32 | The result identifying the hit-test context. |
OnActiveControllerChanged(EventArgs)
Raises the ActiveControllerChanged event.
Declaration
protected virtual void OnActiveControllerChanged(EventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.EventArgs | e | A System.EventArgs that contains the event data. |
OnDrop(DragEventArgs)
Declaration
public void OnDrop(DragEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.DragEventArgs | e |
OnMouseDown(MouseButtonEventArgs)
Invoked when an unhandled System.Windows.Input.Mouse.MouseDownEvent�attached event is raised on the host element.
Declaration
public void OnMouseDown(MouseButtonEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.Input.MouseButtonEventArgs | e | The System.Windows.Input.MouseButtonEventArgs instance containing the event data. |
OnMouseEnter(MouseEventArgs)
Invoked when an unhandled System.Windows.Input.Mouse.MouseEnterEvent�attached event is raised on the host element.
Declaration
public void OnMouseEnter(MouseEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.Input.MouseEventArgs | e | The System.Windows.Input.MouseEventArgs instance containing the event data. |
OnMouseLeave(MouseEventArgs)
Invoked when an unhandled System.Windows.Input.Mouse.MouseLeaveEvent�attached event is raised on the host element.
Declaration
public void OnMouseLeave(MouseEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.Input.MouseEventArgs | e | The System.Windows.Input.MouseEventArgs instance containing the event data. |
OnMouseMove(MouseEventArgs)
Invoked when an unhandled System.Windows.Input.Mouse.MouseMoveEvent�attached event is raised on the host element.
Declaration
public void OnMouseMove(MouseEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.Input.MouseEventArgs | e | The System.Windows.Input.MouseEventArgs instance containing the event data. |
OnMouseUp(MouseButtonEventArgs)
Invoked when an unhandled System.Windows.Input.Mouse.MouseUpEvent�attached event is raised on the host element.
Declaration
public void OnMouseUp(MouseButtonEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.Input.MouseButtonEventArgs | e | The System.Windows.Input.MouseButtonEventArgs instance containing the event data. |
OnMouseWheel(MouseWheelEventArgs)
Invoked when an unhandled System.Windows.Input.Mouse.MouseWheelEvent�attached event is raised on the host element.
Declaration
public void OnMouseWheel(MouseWheelEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.Input.MouseWheelEventArgs | e | The System.Windows.Input.MouseWheelEventArgs instance containing the event data. |
OnPreviewMouseDown(MouseButtonEventArgs)
Invoked when an unhandled System.Windows.Input.Mouse.PreviewMouseDownEvent�attached event is raised on the host element.
Declaration
public void OnPreviewMouseDown(MouseButtonEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.Input.MouseButtonEventArgs | e | The System.Windows.Input.MouseButtonEventArgs instance containing the event data. |
OnPreviewMouseMove(MouseEventArgs)
Invoked when an unhandled System.Windows.Input.Mouse.PreviewMouseMoveEvent�attached event is raised on the host element.
Declaration
public void OnPreviewMouseMove(MouseEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.Input.MouseEventArgs | e | The System.Windows.Input.MouseEventArgs instance containing the event data. |
OnPreviewMouseUp(MouseButtonEventArgs)
Invoked when an unhandled System.Windows.Input.Mouse.PreviewMouseUpEvent�attached event is raised on the host element.
Declaration
public void OnPreviewMouseUp(MouseButtonEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.Input.MouseButtonEventArgs | e | The System.Windows.Input.MouseButtonEventArgs instance containing the event data. |
OnPreviewMouseWheel(MouseWheelEventArgs)
Invoked when an unhandled System.Windows.Input.Mouse.PreviewMouseWheelEvent�attached event is raised on the host element.
Declaration
public void OnPreviewMouseWheel(MouseWheelEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.Input.MouseWheelEventArgs | e | The System.Windows.Input.MouseWheelEventArgs instance containing the event data. |
OnTrackMouseChanged(EventArgs)
Raises the TrackMouseChanged event.
Declaration
protected virtual void OnTrackMouseChanged(EventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.EventArgs | e | A System.EventArgs that contains the event data. |
QueryWantsMouseInput(MouseDevice)
Queries the WantsMouseInputProperty attached property of the element the mouse is directly over.
Declaration
protected virtual bool QueryWantsMouseInput(MouseDevice mouseDevice)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.Input.MouseDevice | mouseDevice | The mouse device. |
Returns
Type |
---|
System.Boolean |
Remove(IMouseController)
Removes a mouse controller.
Declaration
public void Remove(IMouseController controller)
Parameters
Type | Name | Description |
---|---|---|
IMouseController | controller |
ResetTrackMouse()
Resets support for mouse tracking.
Declaration
public void ResetTrackMouse()
Remarks
Call this method after a user interaction that should switch the control back into normal mouse behavior. For example, when the control gets the focus or when the user clicks a scrollbar.
RestoreMode()
Restores the previously saved mode from suspend state created with CreateSuspendState().
Declaration
public void RestoreMode()
ResumeMouse()
Resumes handline mouse events.
Declaration
public void ResumeMouse()
SetHost(FrameworkElement)
Sets the host.
Declaration
public void SetHost(FrameworkElement host)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.FrameworkElement | host | The host. |
SetMouseHoverController(IMouseController, MouseEventArgs)
Sets the controller that will receive mouse hovering messages. If the controller is changed, MouseHoverLeave and MouseHoverEnter calls are made.
Declaration
protected void SetMouseHoverController(IMouseController value, MouseEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
IMouseController | value | |
System.Windows.Input.MouseEventArgs | e |
StartTrackMouse()
Call this from controllers MouseUp method when you want to enable mouse tracking when user release mouse button (e.g. let user click on a line and then resize the line without mouse being pressed down).
Declaration
public void StartTrackMouse()
SuspendMouse()
Suspends handling mouse events.
Declaration
public void SuspendMouse()
ToString()
Declaration
public override string ToString()
Returns
Type |
---|
System.String |
Events
ActiveControllerChanged
Indicates that the active controller has changed.
Declaration
public event EventHandler ActiveControllerChanged
Event Type
Type |
---|
System.EventHandler |
Remarks
Active controller is the controller that is receiving MouseDown, MouseMove and MouseUp messages when the user has pressed a mouse button.
TrackMouseChanged
Indicates that the value of the TrackMouse property has changed.
Declaration
public event EventHandler TrackMouseChanged
Event Type
Type |
---|
System.EventHandler |