Interface IMouseGrabHandler
Defines a contract for tracking which View (if any) has 'grabbed' the mouse, giving it exclusive priority for mouse events such as movement, button presses, and release.
This is typically used for scenarios like dragging, scrolling, or any interaction where a view needs to receive all mouse events until the operation completes (e.g., a scrollbar thumb being dragged).
Usage pattern:
- Call GrabMouse(View?) to route all mouse events to a specific view.
- Call UngrabMouse() to release the grab and restore normal mouse routing.
- Listen to GrabbingMouse, GrabbedMouse, UnGrabbingMouse, and UnGrabbedMouse for grab lifecycle events.
public interface IMouseGrabHandler
Properties
- MouseGrabView
Gets the view that currently has grabbed the mouse (e.g., for dragging).
When this property is not null, all mouse events are routed to this view until UngrabMouse() is called or the mouse is released.
Methods
- GrabMouse(View?)
Grabs the mouse, forcing all mouse events to be routed to the specified view until UngrabMouse() is called.
- UngrabMouse()
Releases the mouse grab, so mouse events will be routed to the view under the mouse pointer.
Events
- GrabbedMouse
Occurs after a view has grabbed the mouse.
This event is raised after the mouse grab operation is complete and the specified view will receive all mouse events.
- GrabbingMouse
Occurs when a view requests to grab the mouse; can be canceled.
Handlers can set
e.Cancel
to true to prevent the grab.
- UnGrabbedMouse
Occurs after a view has released the mouse grab.
This event is raised after the mouse grab has been released and normal mouse routing resumes.
- UnGrabbingMouse
Occurs when a view requests to release the mouse grab; can be canceled.
Handlers can set
e.Cancel
to true to prevent the ungrab.