namespace Terminal.Gui; public partial class View { /// Gets or sets a value indicating whether this want continuous button pressed event. public virtual bool WantContinuousButtonPressed { get; set; } /// Gets or sets a value indicating whether this wants mouse position reports. /// if want mouse position reports; otherwise, . public virtual bool WantMousePositionReports { get; set; } /// Event fired when a mouse event is generated. public event EventHandler MouseClick; /// Event fired when the view receives the mouse event for the first time. public event EventHandler MouseEnter; /// Event fired when the view receives a mouse event for the last time. public event EventHandler MouseLeave; /// public override bool OnMouseEnter (MouseEvent mouseEvent) { if (!Enabled) { return true; } if (!CanBeVisible (this)) { return false; } var args = new MouseEventEventArgs (mouseEvent); MouseEnter?.Invoke (this, args); return args.Handled || base.OnMouseEnter (mouseEvent); } /// Method invoked when a mouse event is generated /// /// The coordinates are relative to . /// /// true, if the event was handled, false otherwise. /// Contains the details about the mouse event. //public virtual bool MouseEvent (MouseEvent mouseEvent) { return false; } /// Method invoked when a mouse event is generated /// /// , if the event was handled, otherwise. public virtual bool OnMouseEvent (MouseEvent mouseEvent) { if (!Enabled) { return true; } if (!CanBeVisible (this)) { return false; } var args = new MouseEventEventArgs (mouseEvent); //if (MouseEvent (mouseEvent)) //{ // return true; //} if (mouseEvent.Flags == MouseFlags.Button1Clicked) { if (CanFocus && !HasFocus && SuperView is { }) { SuperView.SetFocus (this); SetNeedsDisplay (); } return OnMouseClick (args); } if (mouseEvent.Flags == MouseFlags.Button2Clicked) { return OnMouseClick (args); } if (mouseEvent.Flags == MouseFlags.Button3Clicked) { return OnMouseClick (args); } if (mouseEvent.Flags == MouseFlags.Button4Clicked) { return OnMouseClick (args); } return false; } /// public override bool OnMouseLeave (MouseEvent mouseEvent) { if (!Enabled) { return true; } if (!CanBeVisible (this)) { return false; } var args = new MouseEventEventArgs (mouseEvent); MouseLeave?.Invoke (this, args); return args.Handled || base.OnMouseLeave (mouseEvent); } /// Invokes the MouseClick event. protected bool OnMouseClick (MouseEventEventArgs args) { if (!Enabled) { return true; } MouseClick?.Invoke (this, args); return args.Handled; } }