Table of Contents

Method NewMouseEvent

Namespace
Terminal.Gui.ViewBase
Assembly
Terminal.Gui.dll

NewMouseEvent(MouseEventArgs)

Processes a mouse event for this view. This is the main entry point for mouse input handling, called by RaiseMouseEvent(MouseEventArgs) when the mouse interacts with this view.

public bool? NewMouseEvent(MouseEventArgs mouseEvent)

Parameters

mouseEvent MouseEventArgs

The mouse event to process. Coordinates in Position are relative to the view's Viewport.

Returns

bool?

true if the event was handled and should not be propagated; false if the event was not handled and should continue propagating; null if the view declined to handle the event (e.g., disabled or not visible).

Remarks

This method orchestrates the complete mouse event handling pipeline:

  1. Validates pre-conditions (view must be enabled and visible)
  2. Raises MouseEvent for low-level handling via OnMouseEvent(MouseEventArgs) and event subscribers
  3. Handles mouse grab scenarios when HighlightStates or WantContinuousButtonPressed are set (press/release/click)
  4. Invokes commands bound to mouse clicks via MouseBindings (default: Command.Select → Selecting event)
  5. Handles mouse wheel events via OnMouseWheel(MouseEventArgs) and MouseWheel

Continuous Button Press: When WantContinuousButtonPressed is true and the user holds a mouse button down, this method is repeatedly called with Button1Pressed (or Button2-4) events, enabling repeating button behavior (e.g., scroll buttons).

Mouse Grab: Views with HighlightStates or WantContinuousButtonPressed enabled automatically grab the mouse on button press, receiving all subsequent mouse events until the button is released, even if the mouse moves outside the view's Viewport.

Most views should handle mouse clicks by subscribing to the Activating event or overriding OnActivating(CommandEventArgs) rather than overriding this method. Override this method only for custom low-level mouse handling (e.g., drag-and-drop).

See Also