diff --git a/Terminal.Gui/Input/MouseEventEventArgs.cs b/Terminal.Gui/Input/MouseEventEventArgs.cs
index 89fc168a7..79aaff00d 100644
--- a/Terminal.Gui/Input/MouseEventEventArgs.cs
+++ b/Terminal.Gui/Input/MouseEventEventArgs.cs
@@ -5,11 +5,11 @@
/// the wrapped class and is used for the events defined on and subclasses
/// of View (e.g. and ).
///
-public class MouseEventEventArgs : EventArgs
+public class MouseEventArgs : EventArgs
{
/// Constructs.
/// The mouse event.
- public MouseEventEventArgs (MouseEvent me) { MouseEvent = me; }
+ public MouseEventArgs (MouseEvent me) { MouseEvent = me; }
///
/// Indicates if the current mouse event has already been processed and the driver should stop notifying any other
diff --git a/Terminal.Gui/View/Adornment/Border.cs b/Terminal.Gui/View/Adornment/Border.cs
index 73f1aa68f..a9c87919a 100644
--- a/Terminal.Gui/View/Adornment/Border.cs
+++ b/Terminal.Gui/View/Adornment/Border.cs
@@ -264,11 +264,6 @@ public class Border : Adornment
///
protected override bool OnMouseEvent (MouseEvent mouseEvent)
{
- if (base.RaiseMouseEvent (mouseEvent))
- {
- return true;
- }
-
// BUGBUG: See https://github.com/gui-cs/Terminal.Gui/issues/3312
if (!_dragPosition.HasValue && mouseEvent.Flags.HasFlag (MouseFlags.Button1Pressed)
// HACK: Prevents Window from being draggable if it's Top
diff --git a/Terminal.Gui/View/View.Mouse.cs b/Terminal.Gui/View/View.Mouse.cs
index 91ca12bdb..e6d81687c 100644
--- a/Terminal.Gui/View/View.Mouse.cs
+++ b/Terminal.Gui/View/View.Mouse.cs
@@ -245,15 +245,11 @@ public partial class View // Mouse APIs
}
// Cancellable event
- if (RaiseMouseEvent (mouseEvent))
+ if (RaiseMouseEvent (mouseEvent) || mouseEvent.Handled)
{
- // Technically mouseEvent.Handled should already be true if implementers of OnMouseEvent
- // follow the rules. But we'll update it just in case.
- return mouseEvent.Handled = true;
+ return true;
}
- // BUGBUG: MouseEvent should be fired from here. Fix this in https://github.com/gui-cs/Terminal.Gui/issues/3029
-
// Post-Conditions
if (HighlightStyle != HighlightStyle.None || (WantContinuousButtonPressed && WantMousePositionReports))
{
@@ -303,7 +299,7 @@ public partial class View // Mouse APIs
/// , if the event was handled, otherwise.
public bool RaiseMouseEvent (MouseEvent mouseEvent)
{
- var args = new MouseEventEventArgs (mouseEvent);
+ var args = new MouseEventArgs (mouseEvent);
if (OnMouseEvent (mouseEvent) || mouseEvent.Handled == true)
{
@@ -334,7 +330,7 @@ public partial class View // Mouse APIs
/// The coordinates are relative to .
///
///
- public event EventHandler? MouseEvent;
+ public event EventHandler? MouseEvent;
#endregion Low Level Mouse Events
@@ -351,7 +347,7 @@ public partial class View // Mouse APIs
/// The coordinates are relative to .
///
///
- public event EventHandler? MouseClick;
+ public event EventHandler? MouseClick;
/// Invokes the MouseClick event.
///
@@ -361,7 +357,7 @@ public partial class View // Mouse APIs
///
///
/// , if the event was handled, otherwise.
- protected bool OnMouseClick (MouseEventEventArgs args)
+ protected bool OnMouseClick (MouseEventArgs args)
{
// BUGBUG: This should be named NewMouseClickEvent. Fix this in https://github.com/gui-cs/Terminal.Gui/issues/3029
diff --git a/Terminal.Gui/Views/Bar.cs b/Terminal.Gui/Views/Bar.cs
index ddaa44436..8e570eaf9 100644
--- a/Terminal.Gui/Views/Bar.cs
+++ b/Terminal.Gui/Views/Bar.cs
@@ -45,7 +45,7 @@ public class Bar : View, IOrientation, IDesignable
}
}
- private void OnMouseEvent (object? sender, MouseEventEventArgs e)
+ private void OnMouseEvent (object? sender, MouseEventArgs e)
{
NavigationDirection direction = NavigationDirection.Backward;
diff --git a/Terminal.Gui/Views/Button.cs b/Terminal.Gui/Views/Button.cs
index e29043ed9..f642f23d9 100644
--- a/Terminal.Gui/Views/Button.cs
+++ b/Terminal.Gui/Views/Button.cs
@@ -125,7 +125,7 @@ public class Button : View, IDesignable
}
}
- private void Button_MouseClick (object sender, MouseEventEventArgs e)
+ private void Button_MouseClick (object sender, MouseEventArgs e)
{
if (e.Handled)
{
diff --git a/Terminal.Gui/Views/ColorPicker.16.cs b/Terminal.Gui/Views/ColorPicker.16.cs
index c0ae78717..b3a294369 100644
--- a/Terminal.Gui/Views/ColorPicker.16.cs
+++ b/Terminal.Gui/Views/ColorPicker.16.cs
@@ -181,7 +181,7 @@ public class ColorPicker16 : View
// TODO: Decouple Cursor from SelectedColor so that mouse press-and-hold can show the color under the cursor.
- private void ColorPicker_MouseClick (object sender, MouseEventEventArgs me)
+ private void ColorPicker_MouseClick (object sender, MouseEventArgs me)
{
// if (CanFocus)
{
diff --git a/Terminal.Gui/Views/ComboBox.cs b/Terminal.Gui/Views/ComboBox.cs
index 5f2cf7a0a..f1aaf3f9c 100644
--- a/Terminal.Gui/Views/ComboBox.cs
+++ b/Terminal.Gui/Views/ComboBox.cs
@@ -836,17 +836,10 @@ public class ComboBox : View, IDesignable
set => _hideDropdownListOnClick = WantContinuousButtonPressed = value;
}
- // BUGBUG: OnMouseEvent is internal!
protected override bool OnMouseEvent (MouseEvent me)
{
- var res = false;
bool isMousePositionValid = IsMousePositionValid (me);
- if (isMousePositionValid)
- {
- res = base.OnMouseEvent (me);
- }
-
if (HideDropdownListOnClick && me.Flags == MouseFlags.Button1Clicked)
{
if (!isMousePositionValid && !_isFocusing)
@@ -879,7 +872,7 @@ public class ComboBox : View, IDesignable
return true;
}
- return res;
+ return false;
}
public override void OnDrawContent (Rectangle viewport)
diff --git a/Terminal.Gui/Views/DateField.cs b/Terminal.Gui/Views/DateField.cs
index c2a2acbed..0abc62984 100644
--- a/Terminal.Gui/Views/DateField.cs
+++ b/Terminal.Gui/Views/DateField.cs
@@ -116,14 +116,12 @@ public class DateField : TextField
///
protected override bool OnMouseEvent (MouseEvent ev)
{
- bool result = base.OnMouseEvent (ev);
-
- if (result && SelectedLength == 0 && ev.Flags.HasFlag (MouseFlags.Button1Pressed))
+ if (SelectedLength == 0 && ev.Flags.HasFlag (MouseFlags.Button1Pressed))
{
AdjCursorPosition (ev.Position.X);
}
- return result;
+ return ev.Handled;
}
/// Event firing method for the event.
diff --git a/Terminal.Gui/Views/FileDialog.cs b/Terminal.Gui/Views/FileDialog.cs
index 78ed5b584..95d7330a8 100644
--- a/Terminal.Gui/Views/FileDialog.cs
+++ b/Terminal.Gui/Views/FileDialog.cs
@@ -1007,7 +1007,7 @@ public class FileDialog : Dialog
}
}
- private void OnTableViewMouseClick (object sender, MouseEventEventArgs e)
+ private void OnTableViewMouseClick (object sender, MouseEventArgs e)
{
Point? clickedCell = _tableView.ScreenToCell (e.MouseEvent.Position.X, e.MouseEvent.Position.Y, out int? clickedCol);
@@ -1198,7 +1198,7 @@ public class FileDialog : Dialog
private FileSystemInfoStats RowToStats (int rowIndex) { return State?.Children [rowIndex]; }
- private void ShowCellContextMenu (Point? clickedCell, MouseEventEventArgs e)
+ private void ShowCellContextMenu (Point? clickedCell, MouseEventArgs e)
{
if (clickedCell is null)
{
@@ -1222,7 +1222,7 @@ public class FileDialog : Dialog
contextMenu.Show (menuItems);
}
- private void ShowHeaderContextMenu (int clickedCol, MouseEventEventArgs e)
+ private void ShowHeaderContextMenu (int clickedCol, MouseEventArgs e)
{
string sort = GetProposedNewSortOrder (clickedCol, out bool isAsc);
diff --git a/Terminal.Gui/Views/FrameView.cs b/Terminal.Gui/Views/FrameView.cs
index f8b1ffc8b..de2f86215 100644
--- a/Terminal.Gui/Views/FrameView.cs
+++ b/Terminal.Gui/Views/FrameView.cs
@@ -22,7 +22,7 @@ public class FrameView : View
MouseClick += FrameView_MouseClick;
}
- private void FrameView_MouseClick (object sender, MouseEventEventArgs e)
+ private void FrameView_MouseClick (object sender, MouseEventArgs e)
{
// base sets focus on HotKey
e.Handled = InvokeCommand (Command.HotKey, ctx: new (Command.HotKey, key: null, data: this)) == true;
diff --git a/Terminal.Gui/Views/Label.cs b/Terminal.Gui/Views/Label.cs
index 3a76a8a71..07eca7983 100644
--- a/Terminal.Gui/Views/Label.cs
+++ b/Terminal.Gui/Views/Label.cs
@@ -32,7 +32,7 @@ public class Label : View, IDesignable
}
// TODO: base raises Select, but we want to raise HotKey. This can be simplified?
- private void Label_MouseClick (object sender, MouseEventEventArgs e)
+ private void Label_MouseClick (object sender, MouseEventArgs e)
{
if (!CanFocus)
{
diff --git a/Terminal.Gui/Views/RadioGroup.cs b/Terminal.Gui/Views/RadioGroup.cs
index 5cfd9f72b..c45ae6e47 100644
--- a/Terminal.Gui/Views/RadioGroup.cs
+++ b/Terminal.Gui/Views/RadioGroup.cs
@@ -220,7 +220,7 @@ public class RadioGroup : View, IDesignable, IOrientation
///
public bool DoubleClickAccepts { get; set; } = true;
- private void RadioGroup_MouseClick (object? sender, MouseEventEventArgs e)
+ private void RadioGroup_MouseClick (object? sender, MouseEventArgs e)
{
if (e.MouseEvent.Flags.HasFlag (MouseFlags.Button1Clicked))
{
diff --git a/Terminal.Gui/Views/ScrollBarView.cs b/Terminal.Gui/Views/ScrollBarView.cs
index 53da7b181..5eb955fb2 100644
--- a/Terminal.Gui/Views/ScrollBarView.cs
+++ b/Terminal.Gui/Views/ScrollBarView.cs
@@ -777,7 +777,7 @@ public class ScrollBarView : View
// }
//}
- private void ContentBottomRightCorner_MouseClick (object sender, MouseEventEventArgs me)
+ private void ContentBottomRightCorner_MouseClick (object sender, MouseEventArgs me)
{
if (me.MouseEvent.Flags == MouseFlags.WheeledDown
|| me.MouseEvent.Flags == MouseFlags.WheeledUp
diff --git a/Terminal.Gui/Views/TabView.cs b/Terminal.Gui/Views/TabView.cs
index 9d770ffdc..8de57757a 100644
--- a/Terminal.Gui/Views/TabView.cs
+++ b/Terminal.Gui/Views/TabView.cs
@@ -508,7 +508,7 @@ public class TabView : View
return Style.ShowTopLine ? 3 : 2;
}
- private void Tab_MouseClick (object sender, MouseEventEventArgs e)
+ private void Tab_MouseClick (object sender, MouseEventArgs e)
{
e.Handled = _tabsBar.NewMouseEvent (e.MouseEvent) == true;
}
diff --git a/Terminal.Gui/Views/TableView/CheckBoxTableSourceWrapper.cs b/Terminal.Gui/Views/TableView/CheckBoxTableSourceWrapper.cs
index 8be294c1a..d0f7fed26 100644
--- a/Terminal.Gui/Views/TableView/CheckBoxTableSourceWrapper.cs
+++ b/Terminal.Gui/Views/TableView/CheckBoxTableSourceWrapper.cs
@@ -150,7 +150,7 @@ public abstract class CheckBoxTableSourceWrapperBase : ITableSource
tableView.SetNeedsDisplay ();
}
- private void TableView_MouseClick (object sender, MouseEventEventArgs e)
+ private void TableView_MouseClick (object sender, MouseEventArgs e)
{
// we only care about clicks (not movements)
if (!e.MouseEvent.Flags.HasFlag (MouseFlags.Button1Clicked))
diff --git a/Terminal.Gui/Views/TableView/TreeTableSource.cs b/Terminal.Gui/Views/TableView/TreeTableSource.cs
index f2cab6509..88ab0cb3a 100644
--- a/Terminal.Gui/Views/TableView/TreeTableSource.cs
+++ b/Terminal.Gui/Views/TableView/TreeTableSource.cs
@@ -166,7 +166,7 @@ public class TreeTableSource : IEnumerableTableSource, IDisposable where T
}
}
- private void Table_MouseClick (object sender, MouseEventEventArgs e)
+ private void Table_MouseClick (object sender, MouseEventArgs e)
{
Point? hit = _tableView.ScreenToCell (e.MouseEvent.Position.X, e.MouseEvent.Position.Y, out int? headerIfAny, out int? offsetX);
diff --git a/Terminal.Gui/Views/TimeField.cs b/Terminal.Gui/Views/TimeField.cs
index 63736c7da..d32ea9d22 100644
--- a/Terminal.Gui/Views/TimeField.cs
+++ b/Terminal.Gui/Views/TimeField.cs
@@ -165,15 +165,13 @@ public class TimeField : TextField
///
protected override bool OnMouseEvent (MouseEvent ev)
{
- bool result = base.OnMouseEvent (ev);
-
- if (result && SelectedLength == 0 && ev.Flags.HasFlag (MouseFlags.Button1Pressed))
+ if (SelectedLength == 0 && ev.Flags.HasFlag (MouseFlags.Button1Pressed))
{
int point = ev.Position.X;
AdjCursorPosition (point);
}
- return result;
+ return ev.Handled;
}
///
diff --git a/Terminal.Gui/Views/Toplevel.cs b/Terminal.Gui/Views/Toplevel.cs
index cfcdcc14d..ddee6b041 100644
--- a/Terminal.Gui/Views/Toplevel.cs
+++ b/Terminal.Gui/Views/Toplevel.cs
@@ -62,7 +62,7 @@ public partial class Toplevel : View
///
public bool Modal { get; set; }
- private void Toplevel_MouseClick (object? sender, MouseEventEventArgs e) { e.Handled = InvokeCommand (Command.HotKey) == true; }
+ private void Toplevel_MouseClick (object? sender, MouseEventArgs e) { e.Handled = InvokeCommand (Command.HotKey) == true; }
#endregion
diff --git a/UICatalog/Scenarios/ASCIICustomButton.cs b/UICatalog/Scenarios/ASCIICustomButton.cs
index 661efd80d..c1a906a4d 100644
--- a/UICatalog/Scenarios/ASCIICustomButton.cs
+++ b/UICatalog/Scenarios/ASCIICustomButton.cs
@@ -127,7 +127,7 @@ public class ASCIICustomButtonTest : Scenario
}
public event Action PointerEnter;
- private void This_MouseClick (object sender, MouseEventEventArgs obj) { NewMouseEvent (obj.MouseEvent); }
+ private void This_MouseClick (object sender, MouseEventArgs obj) { NewMouseEvent (obj.MouseEvent); }
}
public class ScrollViewTestWindow : Window
@@ -310,7 +310,7 @@ public class ASCIICustomButtonTest : Scenario
}
}
- private void Button_MouseClick (object sender, MouseEventEventArgs obj)
+ private void Button_MouseClick (object sender, MouseEventArgs obj)
{
if (obj.MouseEvent.Flags == MouseFlags.WheeledDown)
{
diff --git a/UICatalog/Scenarios/Bars.cs b/UICatalog/Scenarios/Bars.cs
index 63fdbd85f..23b13cee5 100644
--- a/UICatalog/Scenarios/Bars.cs
+++ b/UICatalog/Scenarios/Bars.cs
@@ -187,7 +187,7 @@ public class Bars : Scenario
menuLikeExamples.MouseClick += MenuLikeExamplesMouseClick;
- void MenuLikeExamplesMouseClick (object sender, MouseEventEventArgs e)
+ void MenuLikeExamplesMouseClick (object sender, MouseEventArgs e)
{
if (e.MouseEvent.Flags.HasFlag (MouseFlags.Button3Clicked))
{
diff --git a/UICatalog/Scenarios/CharacterMap.cs b/UICatalog/Scenarios/CharacterMap.cs
index 5e246f9df..caebcb406 100644
--- a/UICatalog/Scenarios/CharacterMap.cs
+++ b/UICatalog/Scenarios/CharacterMap.cs
@@ -527,7 +527,7 @@ internal class CharMap : View
Padding.Add (up, down, left, right);
}
- private void Handle_MouseEvent (object sender, MouseEventEventArgs e)
+ private void Handle_MouseEvent (object sender, MouseEventArgs e)
{
if (e.MouseEvent.Flags == MouseFlags.WheeledDown)
{
@@ -839,7 +839,7 @@ internal class CharMap : View
private void CopyCodePoint () { Clipboard.Contents = $"U+{SelectedCodePoint:x5}"; }
private void CopyGlyph () { Clipboard.Contents = $"{new Rune (SelectedCodePoint)}"; }
- private void Handle_MouseClick (object sender, MouseEventEventArgs args)
+ private void Handle_MouseClick (object sender, MouseEventArgs args)
{
MouseEvent me = args.MouseEvent;
diff --git a/UICatalog/Scenarios/ContentScrolling.cs b/UICatalog/Scenarios/ContentScrolling.cs
index 028717fcd..8c97d3e2a 100644
--- a/UICatalog/Scenarios/ContentScrolling.cs
+++ b/UICatalog/Scenarios/ContentScrolling.cs
@@ -52,7 +52,7 @@ public class ContentScrolling : Scenario
MouseEvent += VirtualDemoView_MouseEvent;
}
- private void VirtualDemoView_MouseEvent (object sender, MouseEventEventArgs e)
+ private void VirtualDemoView_MouseEvent (object sender, MouseEventArgs e)
{
if (e.MouseEvent.Flags == MouseFlags.WheeledDown)
{
diff --git a/UICatalog/Scenarios/TableEditor.cs b/UICatalog/Scenarios/TableEditor.cs
index d127f8610..eaeab748e 100644
--- a/UICatalog/Scenarios/TableEditor.cs
+++ b/UICatalog/Scenarios/TableEditor.cs
@@ -1254,7 +1254,7 @@ public class TableEditor : Scenario
_tableView.Update ();
}
- private void ShowHeaderContextMenu (int clickedCol, MouseEventEventArgs e)
+ private void ShowHeaderContextMenu (int clickedCol, MouseEventArgs e)
{
if (HasCheckboxes () && clickedCol == 0)
{
diff --git a/UICatalog/Scenarios/TreeViewFileSystem.cs b/UICatalog/Scenarios/TreeViewFileSystem.cs
index 590af81b1..ae288a5df 100644
--- a/UICatalog/Scenarios/TreeViewFileSystem.cs
+++ b/UICatalog/Scenarios/TreeViewFileSystem.cs
@@ -484,7 +484,7 @@ public class TreeViewFileSystem : Scenario
}
}
- private void TreeViewFiles_MouseClick (object sender, MouseEventEventArgs obj)
+ private void TreeViewFiles_MouseClick (object sender, MouseEventArgs obj)
{
// if user right clicks
if (obj.MouseEvent.Flags.HasFlag (MouseFlags.Button3Clicked))