Table of Contents

Method IsGrabbed

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

IsGrabbed(View?)

Determines whether the specified view currently has the mouse grabbed.

bool IsGrabbed(View? view)

Parameters

view View

The view to check. If null, returns false.

Returns

bool

true if the specified view currently has the mouse grabbed; otherwise, false.

Examples

if (App.Mouse.IsGrabbed(this))
{
    // Process drag event
    UpdatePosition(mouse.Position);
}

Remarks

This method uses reference equality (ReferenceEquals(object, object)) to check if the given view is the one that currently has exclusive mouse event routing.

Automatic Cleanup: If the grabbed view has been disposed or garbage collected, this method returns false because the internal WeakReference<T> will no longer resolve to a live object.

Use Cases:

  • Check if this view owns the grab before processing mouse events.
  • Implement grab arbitration in GrabbingMouse handlers.
  • Conditional logic based on whether the view is actively dragging.
See Also

IsGrabbed()

Determines whether any view currently has the mouse grabbed.

bool IsGrabbed()

Returns

bool

true if any view currently has the mouse grabbed; otherwise, false.

Examples

if (!App.Mouse.IsGrabbed())
{
    // No view has the mouse grabbed - safe to proceed
    App.Mouse.GrabMouse(this);
}

Remarks

Use this method to check if the mouse grab is active without knowing which specific view holds it.

Automatic Cleanup: If the grabbed view has been disposed or garbage collected, this method returns false because the internal WeakReference<T> will no longer resolve to a live object.

See Also