Table of Contents

Event GrabbingMouse

Namespace
Terminal.Gui.App
Assembly
Terminal.Gui.dll

Raised when a view requests to grab the mouse; can be cancelled.

event EventHandler<GrabMouseEventArgs>? GrabbingMouse

Returns

EventHandler<GrabMouseEventArgs>
Raised when a view requests to grab the mouse; can be cancelled.

Examples

// Prevent other views from grabbing during an active drag
App.Mouse.GrabbingMouse += (sender, e) =>
{
    if (_isDragging && !ReferenceEquals(e.View, this))
    {
        e.Cancel = true;
    }
};

Remarks

This event fires before the grab is established. Handlers can set Cancel to true to prevent the grab from occurring.

Use this event to implement grab arbitration logic, such as preventing one view from stealing the mouse grab from another view during an active drag operation.

The View property contains the view attempting to grab the mouse.