Table of Contents

Method HandleMouseGrab

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

HandleMouseGrab(View?, Mouse)

INTERNAL: Handles mouse grab logic for a mouse event, routing events to the grabbed view if one exists.

bool HandleMouseGrab(View? deepestViewUnderMouse, Mouse mouse)

Parameters

deepestViewUnderMouse View

The deepest view under the mouse according to normal hit-testing. This parameter is not used when a view has the mouse grabbed, but is included for context.

mouse Mouse

The mouse event to handle. If a view has the grab, coordinates are converted to the grabbed view's viewport and the event is delivered to that view via NewMouseEvent(Mouse).

Returns

bool

true if a view had the mouse grabbed and the event was routed to it (regardless of whether the grabbed view marked it as handled); false if no view has the grab and normal mouse routing should proceed.

Remarks

This method is called by RaiseMouseEvent(Mouse) early in the mouse event processing pipeline. When a view has grabbed the mouse:

  1. The event coordinates are converted to the grabbed view's viewport coordinates.
  2. The event is delivered directly to the grabbed view via NewMouseEvent(Mouse).
  3. true is returned to prevent further event propagation.

This ensures that during drag operations, only the grabbing view receives mouse events, preventing other views from interfering with the drag (e.g., receiving Enter/Leave events).