Table of Contents

Method GrabMouse

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

GrabMouse(View?)

Grabs the mouse, forcing all mouse events to be routed exclusively to the specified view until UngrabMouse() is called.

void GrabMouse(View? view)

Parameters

view View

The View that will receive all mouse events until UngrabMouse() is invoked. If null, equivalent to calling UngrabMouse().

Remarks

Event Sequence: GrabbingMouse → (if not cancelled) → GrabbedMouse

Behavior:

  • If view is null, the current grab is released.
  • If GrabbingMouse is cancelled, the grab does not occur.
  • While grabbed, all mouse events have coordinates converted to the view's viewport.
  • The view is stored via WeakReference<T>, preventing memory leaks if the view is disposed.

Typical Call Sites: In OnMouseEvent(Mouse) when handling LeftButtonPressed (or other button pressed events) to begin a drag operation.

See Also