diff --git a/Terminal.Gui/Input/Responder.cs b/Terminal.Gui/Input/Responder.cs
index d7f2ce6c3f..ea0c339ee0 100644
--- a/Terminal.Gui/Input/Responder.cs
+++ b/Terminal.Gui/Input/Responder.cs
@@ -56,14 +56,6 @@ public void Dispose ()
/// Event raised when has been called to signal that this object is being disposed.
public event EventHandler Disposing;
- /// 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 the property from a view is changed.
public virtual void OnCanFocusChanged () { }
@@ -80,27 +72,6 @@ public virtual void OnEnabledChanged () { }
/// true, if the event was handled, false otherwise.
public virtual bool OnLeave (View view) { return false; }
- ///
- /// Called when the mouse first enters the view; the view will now receives mouse events until the mouse leaves
- /// the view. At which time, will be called.
- ///
- ///
- /// The coordinates are relative to .
- ///
- ///
- /// true, if the event was handled, false otherwise.
- public virtual bool OnMouseEnter (MouseEvent mouseEvent) { return false; }
-
- ///
- /// Called when the mouse has moved outside of the view; the view will no longer receive mouse events (until the
- /// mouse moves within the view again and is called).
- ///
- ///
- /// The coordinates are relative to .
- ///
- ///
- /// true, if the event was handled, false otherwise.
- public virtual bool OnMouseLeave (MouseEvent mouseEvent) { return false; }
/// Method invoked when the property from a view is changed.
public virtual void OnVisibleChanged () { }
diff --git a/Terminal.Gui/Text/Autocomplete/AppendAutocomplete.cs b/Terminal.Gui/Text/Autocomplete/AppendAutocomplete.cs
index 887d09791f..ba5fbed5a4 100644
--- a/Terminal.Gui/Text/Autocomplete/AppendAutocomplete.cs
+++ b/Terminal.Gui/Text/Autocomplete/AppendAutocomplete.cs
@@ -59,7 +59,7 @@ public override void GenerateSuggestions (AutocompleteContext context)
}
///
- public override bool MouseEvent (MouseEvent me, bool fromHost = false) { return false; }
+ public override bool OnMouseEvent (MouseEvent me, bool fromHost = false) { return false; }
///
public override bool ProcessKey (Key a)
diff --git a/Terminal.Gui/Text/Autocomplete/AutocompleteBase.cs b/Terminal.Gui/Text/Autocomplete/AutocompleteBase.cs
index 3dfe4955eb..7e6ff1e558 100644
--- a/Terminal.Gui/Text/Autocomplete/AutocompleteBase.cs
+++ b/Terminal.Gui/Text/Autocomplete/AutocompleteBase.cs
@@ -52,7 +52,7 @@ public abstract class AutocompleteBase : IAutocomplete
public virtual AutocompleteContext Context { get; set; }
///
- public abstract bool MouseEvent (MouseEvent me, bool fromHost = false);
+ public abstract bool OnMouseEvent (MouseEvent me, bool fromHost = false);
///
public abstract bool ProcessKey (Key a);
diff --git a/Terminal.Gui/Text/Autocomplete/IAutocomplete.cs b/Terminal.Gui/Text/Autocomplete/IAutocomplete.cs
index ca0e36a8a9..9eac868768 100644
--- a/Terminal.Gui/Text/Autocomplete/IAutocomplete.cs
+++ b/Terminal.Gui/Text/Autocomplete/IAutocomplete.cs
@@ -72,7 +72,7 @@ public interface IAutocomplete
/// The mouse event.
/// If was called from the popup or from the host.
/// trueif the mouse can be handled falseotherwise.
- bool MouseEvent (MouseEvent me, bool fromHost = false);
+ bool OnMouseEvent (MouseEvent me, bool fromHost = false);
///
/// Handle key events before e.g. to make key events like up/down apply to the
diff --git a/Terminal.Gui/Text/Autocomplete/PopupAutocomplete.PopUp.cs b/Terminal.Gui/Text/Autocomplete/PopupAutocomplete.PopUp.cs
index 6fab050728..55a6140759 100644
--- a/Terminal.Gui/Text/Autocomplete/PopupAutocomplete.PopUp.cs
+++ b/Terminal.Gui/Text/Autocomplete/PopupAutocomplete.PopUp.cs
@@ -14,7 +14,7 @@ public Popup (PopupAutocomplete autoComplete)
WantMousePositionReports = true;
}
- public override bool MouseEvent (MouseEvent mouseEvent) { return _autoComplete.MouseEvent (mouseEvent); }
+ protected internal override bool OnMouseEvent (MouseEvent mouseEvent) { return _autoComplete.OnMouseEvent (mouseEvent); }
public override void OnDrawContent (Rectangle contentArea)
{
diff --git a/Terminal.Gui/Text/Autocomplete/PopupAutocomplete.cs b/Terminal.Gui/Text/Autocomplete/PopupAutocomplete.cs
index cf71abf5ae..84ea483657 100644
--- a/Terminal.Gui/Text/Autocomplete/PopupAutocomplete.cs
+++ b/Terminal.Gui/Text/Autocomplete/PopupAutocomplete.cs
@@ -86,7 +86,7 @@ public override void EnsureSelectedIdxIsValid ()
/// The mouse event.
/// If was called from the popup or from the host.
/// trueif the mouse can be handled falseotherwise.
- public override bool MouseEvent (MouseEvent me, bool fromHost = false)
+ public override bool OnMouseEvent (MouseEvent me, bool fromHost = false)
{
if (fromHost)
{
diff --git a/Terminal.Gui/View/View.cs b/Terminal.Gui/View/View.cs
index bb435b7dc3..32d9e584c9 100644
--- a/Terminal.Gui/View/View.cs
+++ b/Terminal.Gui/View/View.cs
@@ -227,6 +227,24 @@ public override bool Visible
/// Event fired when the value is being changed.
public event EventHandler VisibleChanged;
+ ///
+ /// Cancelable event fired when the command is invoked. Set
+ /// to cancel the event.
+ ///
+ public event EventHandler Accept;
+
+ ///
+ /// Called when the command is invoked. Fires the
+ /// event.
+ ///
+ /// If the event was canceled.
+ protected bool? OnAccept ()
+ {
+ var args = new CancelEventArgs ();
+ Accept?.Invoke (this, args);
+ return args.Cancel;
+ }
+
///
protected override void Dispose (bool disposing)
{
diff --git a/Terminal.Gui/View/ViewKeyboard.cs b/Terminal.Gui/View/ViewKeyboard.cs
index 095fb342dd..853515655b 100644
--- a/Terminal.Gui/View/ViewKeyboard.cs
+++ b/Terminal.Gui/View/ViewKeyboard.cs
@@ -24,31 +24,12 @@ private void AddCommands ()
if (CanFocus)
{
SetFocus ();
-
return true;
}
return false;
}
- ///
- /// Cancelable event fired when the command is invoked. Set
- /// to cancel the event.
- ///
- public event EventHandler Accept;
-
- ///
- /// Called when the command is invoked. Fires the
- /// event.
- ///
- /// If the event was canceled.
- public bool? OnAccept ()
- {
- var args = new CancelEventArgs ();
- Accept?.Invoke (this, args);
- return args.Cancel;
- }
-
/// Invoked when the is changed.
public event EventHandler HotKeyChanged;
@@ -505,7 +486,7 @@ public virtual bool OnProcessKeyDown (Key keyEvent)
}
///
- /// Invoked when the users presses a key, allowing subscribers to do things during key down events. Set
+ /// Invoked when the user presses a key, allowing subscribers to do things during key down events. Set
/// to true to stop the key from being processed by other views. Invoked after
/// and before .
///
diff --git a/Terminal.Gui/View/ViewMouse.cs b/Terminal.Gui/View/ViewMouse.cs
index f0f03f72fc..2ab4d54bad 100644
--- a/Terminal.Gui/View/ViewMouse.cs
+++ b/Terminal.Gui/View/ViewMouse.cs
@@ -9,17 +9,35 @@ public partial class View
/// if want mouse position reports; otherwise, .
public virtual bool WantMousePositionReports { get; set; }
- /// Event fired when a mouse event is generated.
+ /// Event fired when a mouse click occurs.
+ ///
+ ///
+ /// Fired when the mouse is either clicked or double-clicked. Check
+ /// to see which button was clicked.
+ ///
+ ///
+ /// The coordinates are relative to .
+ ///
+ ///
public event EventHandler MouseClick;
- /// Event fired when the view receives the mouse event for the first time.
+ /// Event fired when the mouse moves into the View's .
public event EventHandler MouseEnter;
- /// Event fired when the view receives a mouse event for the last time.
+ /// Event fired when the mouse leaves the View's .
public event EventHandler MouseLeave;
- ///
- public override bool OnMouseEnter (MouseEvent mouseEvent)
+ // TODO: OnMouseEnter should not be public virtual, but protected.
+ ///
+ /// Called when the mouse enters the View's . The view will now receive mouse events until the mouse leaves
+ /// the view. At which time, will be called.
+ ///
+ ///
+ /// The coordinates are relative to .
+ ///
+ ///
+ /// , if the event was handled, otherwise.
+ protected internal virtual bool OnMouseEnter (MouseEvent mouseEvent)
{
if (!Enabled)
{
@@ -34,13 +52,20 @@ public override bool OnMouseEnter (MouseEvent mouseEvent)
var args = new MouseEventEventArgs (mouseEvent);
MouseEnter?.Invoke (this, args);
- return args.Handled || base.OnMouseEnter (mouseEvent);
+ return args.Handled;
}
- /// Method invoked when a mouse event is generated
+ // TODO: OnMouseLeave should not be public virtual, but protected.
+ ///
+ /// Called when the mouse has moved out of the View's . The view will no longer receive mouse events (until the
+ /// mouse moves within the view again and is called).
+ ///
+ ///
+ /// The coordinates are relative to .
+ ///
///
/// , if the event was handled, otherwise.
- public virtual bool OnMouseEvent (MouseEvent mouseEvent)
+ protected internal virtual bool OnMouseLeave (MouseEvent mouseEvent)
{
if (!Enabled)
{
@@ -53,34 +78,47 @@ public virtual bool OnMouseEvent (MouseEvent mouseEvent)
}
var args = new MouseEventEventArgs (mouseEvent);
+ MouseLeave?.Invoke (this, args);
+
+ return args.Handled;
+ }
- if (MouseEvent (mouseEvent))
+ // TODO: OnMouseEvent should not be public virtual, but protected.
+ /// Called when a mouse event occurs within the view's .
+ ///
+ ///
+ /// The coordinates are relative to .
+ ///
+ ///
+ ///
+ /// , if the event was handled, otherwise.
+ protected internal virtual bool OnMouseEvent (MouseEvent mouseEvent)
+ {
+ if (!Enabled)
{
return true;
}
- if (mouseEvent.Flags == MouseFlags.Button1Clicked)
+ if (!CanBeVisible (this))
{
- if (CanFocus && !HasFocus && SuperView is { })
- {
- SuperView.SetFocus (this);
- SetNeedsDisplay ();
- }
-
- return OnMouseClick (args);
+ return false;
}
- if (mouseEvent.Flags == MouseFlags.Button2Clicked)
- {
- return OnMouseClick (args);
- }
+ var args = new MouseEventEventArgs (mouseEvent);
- if (mouseEvent.Flags == MouseFlags.Button3Clicked)
+ // Clicked support for all buttons and single and double click
+ if (mouseEvent.Flags.HasFlag (MouseFlags.Button1Clicked)
+ || mouseEvent.Flags.HasFlag (MouseFlags.Button2Clicked)
+ || mouseEvent.Flags.HasFlag (MouseFlags.Button3Clicked)
+ || mouseEvent.Flags.HasFlag (MouseFlags.Button4Clicked))
{
return OnMouseClick (args);
}
- if (mouseEvent.Flags == MouseFlags.Button4Clicked)
+ if (mouseEvent.Flags.HasFlag (MouseFlags.Button1DoubleClicked)
+ || mouseEvent.Flags.HasFlag (MouseFlags.Button2DoubleClicked)
+ || mouseEvent.Flags.HasFlag (MouseFlags.Button3DoubleClicked)
+ || mouseEvent.Flags.HasFlag (MouseFlags.Button4DoubleClicked))
{
return OnMouseClick (args);
}
@@ -88,26 +126,13 @@ public virtual bool OnMouseEvent (MouseEvent mouseEvent)
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.
+ ///
+ ///
+ /// Called when the mouse is either clicked or double-clicked. Check
+ /// to see which button was clicked.
+ ///
+ ///
protected bool OnMouseClick (MouseEventEventArgs args)
{
if (!Enabled)
@@ -116,6 +141,10 @@ protected bool OnMouseClick (MouseEventEventArgs args)
}
MouseClick?.Invoke (this, args);
+ if (args.Handled)
+ {
+ return true;
+ }
return args.Handled;
}
diff --git a/Terminal.Gui/Views/Button.cs b/Terminal.Gui/Views/Button.cs
index 7d76878957..87d9a735dc 100644
--- a/Terminal.Gui/Views/Button.cs
+++ b/Terminal.Gui/Views/Button.cs
@@ -58,6 +58,12 @@ public Button ()
KeyBindings.Add (Key.Enter, Command.HotKey);
TitleChanged += Button_TitleChanged;
+ MouseClick += Button_MouseClick;
+ }
+
+ private void Button_MouseClick (object sender, MouseEventEventArgs e)
+ {
+ e.Handled = InvokeCommand (Command.Accept) == true;
}
private void Button_TitleChanged (object sender, StateEventArgs e)
@@ -99,29 +105,6 @@ public bool IsDefault
///
public bool NoPadding { get; set; }
- ///
- public override bool MouseEvent (MouseEvent me)
- {
- if (me.Flags == MouseFlags.Button1Clicked)
- {
- if (CanFocus && Enabled)
- {
- if (!HasFocus)
- {
- SetFocus ();
- SetNeedsDisplay ();
- Draw ();
- }
-
- OnAccept ();
- }
-
- return true;
- }
-
- return false;
- }
-
///
public override bool OnEnter (View view)
{
diff --git a/Terminal.Gui/Views/CheckBox.cs b/Terminal.Gui/Views/CheckBox.cs
index 9f5f2aadb7..fb8665b872 100644
--- a/Terminal.Gui/Views/CheckBox.cs
+++ b/Terminal.Gui/Views/CheckBox.cs
@@ -34,6 +34,13 @@ public CheckBox ()
KeyBindings.Add (Key.Space, Command.Accept);
TitleChanged += Checkbox_TitleChanged;
+
+ MouseClick += CheckBox_MouseClick;
+ }
+
+ private void CheckBox_MouseClick (object? sender, MouseEventEventArgs e)
+ {
+ e.Handled = OnToggled () == true;
}
private void Checkbox_TitleChanged (object? sender, StateEventArgs e)
@@ -87,17 +94,6 @@ public bool? Checked
}
}
- ///
- public override bool MouseEvent (MouseEvent me)
- {
- if (!me.Flags.HasFlag (MouseFlags.Button1Clicked) || !CanFocus)
- {
- return false;
- }
-
- return OnToggled () == true;
- }
-
///
public override bool OnEnter (View view)
{
@@ -143,11 +139,13 @@ public override bool OnEnter (View view)
return e.Cancel;
}
- Checked = e.NewValue;
+ // By default, Command.Accept calls OnAccept, so we need to call it here to ensure that the event is fired.
+ if (OnAccept () == true)
+ {
+ return true;
+ }
- SetNeedsDisplay ();
- SetFocus ();
- OnAccept ();
+ Checked = e.NewValue;
return true;
}
diff --git a/Terminal.Gui/Views/ColorPicker.cs b/Terminal.Gui/Views/ColorPicker.cs
index 8c0396b312..e1f8179a51 100644
--- a/Terminal.Gui/Views/ColorPicker.cs
+++ b/Terminal.Gui/Views/ColorPicker.cs
@@ -89,7 +89,7 @@ public ColorName SelectedColor
public event EventHandler ColorChanged;
///
- public override bool MouseEvent (MouseEvent me)
+ protected internal override bool OnMouseEvent (MouseEvent me)
{
if (!me.Flags.HasFlag (MouseFlags.Button1Clicked) || !CanFocus)
{
diff --git a/Terminal.Gui/Views/ComboBox.cs b/Terminal.Gui/Views/ComboBox.cs
index cc8b1fd26a..ced2bcb05b 100644
--- a/Terminal.Gui/Views/ComboBox.cs
+++ b/Terminal.Gui/Views/ComboBox.cs
@@ -243,7 +243,7 @@ public virtual bool Expand ()
public event EventHandler Expanded;
///
- public override bool MouseEvent (MouseEvent me)
+ protected internal override bool OnMouseEvent (MouseEvent me)
{
if (me.X == Bounds.Right - 1
&& me.Y == Bounds.Top
@@ -794,14 +794,14 @@ public bool HideDropdownListOnClick
set => _hideDropdownListOnClick = WantContinuousButtonPressed = value;
}
- public override bool MouseEvent (MouseEvent me)
+ protected internal override bool OnMouseEvent (MouseEvent me)
{
var res = false;
bool isMousePositionValid = IsMousePositionValid (me);
if (isMousePositionValid)
{
- res = base.MouseEvent (me);
+ res = base.OnMouseEvent (me);
}
if (HideDropdownListOnClick && me.Flags == MouseFlags.Button1Clicked)
diff --git a/Terminal.Gui/Views/DateField.cs b/Terminal.Gui/Views/DateField.cs
index 21059992c5..05b8c9f297 100644
--- a/Terminal.Gui/Views/DateField.cs
+++ b/Terminal.Gui/Views/DateField.cs
@@ -114,9 +114,9 @@ public override void DeleteCharRight ()
}
///
- public override bool MouseEvent (MouseEvent ev)
+ protected internal override bool OnMouseEvent (MouseEvent ev)
{
- bool result = base.MouseEvent (ev);
+ bool result = base.OnMouseEvent (ev);
if (result && SelectedLength == 0 && ev.Flags.HasFlag (MouseFlags.Button1Pressed))
{
diff --git a/Terminal.Gui/Views/HexView.cs b/Terminal.Gui/Views/HexView.cs
index 700f322c15..a9a7f0aad8 100644
--- a/Terminal.Gui/Views/HexView.cs
+++ b/Terminal.Gui/Views/HexView.cs
@@ -262,7 +262,7 @@ public void ApplyEdits (Stream stream = null)
public event EventHandler Edited;
///
- public override bool MouseEvent (MouseEvent me)
+ protected internal override bool OnMouseEvent (MouseEvent me)
{
// BUGBUG: Test this with a border! Assumes Frame == Bounds!
diff --git a/Terminal.Gui/Views/Label.cs b/Terminal.Gui/Views/Label.cs
index 5f04cfee39..e4e6b5ac97 100644
--- a/Terminal.Gui/Views/Label.cs
+++ b/Terminal.Gui/Views/Label.cs
@@ -25,6 +25,12 @@ public Label ()
KeyBindings.Add (Key.Space, Command.Accept);
TitleChanged += Label_TitleChanged;
+ MouseClick += Label_MouseClick;
+ }
+
+ private void Label_MouseClick (object sender, MouseEventEventArgs e)
+ {
+ e.Handled = InvokeCommand (Command.Accept) == true;
}
private void Label_TitleChanged (object sender, StateEventArgs e)
@@ -62,50 +68,6 @@ public override Rune HotKeySpecifier
public override bool OnEnter (View view)
{
Application.Driver.SetCursorVisibility (CursorVisibility.Invisible);
-
return base.OnEnter (view);
}
-
- /// Method invoked when a mouse event is generated
- ///
- /// true, if the event was handled, false otherwise.
- public override bool OnMouseEvent (MouseEvent mouseEvent)
- {
- var args = new MouseEventEventArgs (mouseEvent);
-
- if (OnMouseClick (args))
- {
- return true;
- }
-
- if (MouseEvent (mouseEvent))
- {
- return true;
- }
-
- if (mouseEvent.Flags == MouseFlags.Button1Clicked)
- {
- if (!CanFocus)
- {
- FocusNext ();
- }
-
- if (!HasFocus && SuperView is { })
- {
- if (!SuperView.HasFocus)
- {
- SuperView.SetFocus ();
- }
-
- SetFocus ();
- SetNeedsDisplay ();
- }
-
- OnAccept ();
-
- return true;
- }
-
- return false;
- }
}
diff --git a/Terminal.Gui/Views/ListView.cs b/Terminal.Gui/Views/ListView.cs
index 7efc1f25f1..132be32131 100644
--- a/Terminal.Gui/Views/ListView.cs
+++ b/Terminal.Gui/Views/ListView.cs
@@ -347,7 +347,7 @@ public virtual bool MarkUnmarkRow ()
}
///
- public override bool MouseEvent (MouseEvent me)
+ protected internal override bool OnMouseEvent (MouseEvent me)
{
if (!me.Flags.HasFlag (MouseFlags.Button1Clicked)
&& !me.Flags.HasFlag (MouseFlags.Button1DoubleClicked)
@@ -704,9 +704,10 @@ public bool OnOpenSelectedItem ()
object value = _source.ToList () [_selected];
+ // By default, Command.Accept calls OnAccept, so we need to call it here to ensure that the event is fired.
if (OnAccept () == true)
{
- return false;
+ return true;
}
OpenSelectedItem?.Invoke (this, new ListViewItemEventArgs (_selected, value));
diff --git a/Terminal.Gui/Views/Menu/Menu.cs b/Terminal.Gui/Views/Menu/Menu.cs
index 37de2476ba..1365911cec 100644
--- a/Terminal.Gui/Views/Menu/Menu.cs
+++ b/Terminal.Gui/Views/Menu/Menu.cs
@@ -744,7 +744,7 @@ private void Application_RootMouseEvent (object sender, MouseEventEventArgs a)
View = view
};
- if (MouseEvent (nme) || a.MouseEvent.Flags == MouseFlags.Button1Pressed || a.MouseEvent.Flags == MouseFlags.Button1Released)
+ if (OnMouseEvent (nme) || a.MouseEvent.Flags == MouseFlags.Button1Pressed || a.MouseEvent.Flags == MouseFlags.Button1Released)
{
a.MouseEvent.Handled = true;
}
@@ -1183,7 +1183,7 @@ private void SetParentSetNeedsDisplay ()
_host?.SetNeedsDisplay ();
}
- public override bool MouseEvent (MouseEvent me)
+ protected internal override bool OnMouseEvent (MouseEvent me)
{
if (!_host._handled && !_host.HandleGrabView (me, this))
{
diff --git a/Terminal.Gui/Views/Menu/MenuBar.cs b/Terminal.Gui/Views/Menu/MenuBar.cs
index 165d9721de..69a8ed8c0e 100644
--- a/Terminal.Gui/Views/Menu/MenuBar.cs
+++ b/Terminal.Gui/Views/Menu/MenuBar.cs
@@ -1647,7 +1647,7 @@ public override bool OnLeave (View view)
}
///
- public override bool MouseEvent (MouseEvent me)
+ protected internal override bool OnMouseEvent (MouseEvent me)
{
if (!_handled && !HandleGrabView (me, this))
{
@@ -1805,7 +1805,7 @@ internal bool HandleGrabView (MouseEvent me, View current)
nme = new MouseEvent { X = me.X + current.Frame.X, Y = 0, Flags = me.Flags, View = v };
}
- v.MouseEvent (nme);
+ v.OnMouseEvent (nme);
return false;
}
diff --git a/Terminal.Gui/Views/RadioGroup.cs b/Terminal.Gui/Views/RadioGroup.cs
index cc53cf0bda..82de31e386 100644
--- a/Terminal.Gui/Views/RadioGroup.cs
+++ b/Terminal.Gui/Views/RadioGroup.cs
@@ -161,7 +161,7 @@ public int SelectedItem
}
///
- public override bool MouseEvent (MouseEvent me)
+ protected internal override bool OnMouseEvent (MouseEvent me)
{
if (!me.Flags.HasFlag (MouseFlags.Button1Clicked))
{
diff --git a/Terminal.Gui/Views/ScrollBarView.cs b/Terminal.Gui/Views/ScrollBarView.cs
index 7cb47ffd47..92fcbd505b 100644
--- a/Terminal.Gui/Views/ScrollBarView.cs
+++ b/Terminal.Gui/Views/ScrollBarView.cs
@@ -275,7 +275,7 @@ public int Size
public event EventHandler ChangedPosition;
///
- public override bool MouseEvent (MouseEvent mouseEvent)
+ protected internal override bool OnMouseEvent (MouseEvent mouseEvent)
{
if (mouseEvent.Flags != MouseFlags.Button1Pressed
&& mouseEvent.Flags != MouseFlags.Button1DoubleClicked
@@ -325,7 +325,7 @@ public override bool MouseEvent (MouseEvent mouseEvent)
|| mouseEvent.Flags == MouseFlags.WheeledRight
|| mouseEvent.Flags == MouseFlags.WheeledLeft))
{
- return Host.MouseEvent (mouseEvent);
+ return Host.OnMouseEvent (mouseEvent);
}
if (mouseEvent.Flags == MouseFlags.Button1Pressed && location == 0)
@@ -800,7 +800,7 @@ private void ContentBottomRightCorner_MouseClick (object sender, MouseEventEvent
|| me.MouseEvent.Flags == MouseFlags.WheeledRight
|| me.MouseEvent.Flags == MouseFlags.WheeledLeft)
{
- MouseEvent (me.MouseEvent);
+ OnMouseEvent (me.MouseEvent);
}
else if (me.MouseEvent.Flags == MouseFlags.Button1Clicked)
{
diff --git a/Terminal.Gui/Views/ScrollView.cs b/Terminal.Gui/Views/ScrollView.cs
index 89fb1d6669..286ed77a03 100644
--- a/Terminal.Gui/Views/ScrollView.cs
+++ b/Terminal.Gui/Views/ScrollView.cs
@@ -126,10 +126,11 @@ public ScrollView ()
}
SetContentOffset (_contentOffset);
- _contentView.Frame = new (ContentOffset, ContentSize);
+ _contentView.Frame = new Rectangle (ContentOffset, ContentSize);
+
// PERF: How about calls to Point.Offset instead?
- _vertical.ChangedPosition += delegate { ContentOffset = new (ContentOffset.X, _vertical.Position); };
- _horizontal.ChangedPosition += delegate { ContentOffset = new (_horizontal.Position, ContentOffset.Y); };
+ _vertical.ChangedPosition += delegate { ContentOffset = new Point (ContentOffset.X, _vertical.Position); };
+ _horizontal.ChangedPosition += delegate { ContentOffset = new Point (_horizontal.Position, ContentOffset.Y); };
};
}
@@ -188,7 +189,7 @@ public Size ContentSize
if (_contentSize != value)
{
_contentSize = value;
- _contentView.Frame = new (_contentOffset, value);
+ _contentView.Frame = new Rectangle (_contentOffset, value);
_vertical.Size = _contentSize.Height;
_horizontal.Size = _contentSize.Width;
SetNeedsDisplay ();
@@ -321,7 +322,7 @@ public override void Add (View view)
}
else
{
- if (!IsOverridden (view, "MouseEvent"))
+ if (!IsOverridden (view, "OnMouseEvent"))
{
view.MouseEnter += View_MouseEnter;
view.MouseLeave += View_MouseLeave;
@@ -333,53 +334,6 @@ public override void Add (View view)
SetNeedsLayout ();
}
- ///
- public override bool MouseEvent (MouseEvent me)
- {
- if (me.Flags != MouseFlags.WheeledDown
- && me.Flags != MouseFlags.WheeledUp
- && me.Flags != MouseFlags.WheeledRight
- && me.Flags != MouseFlags.WheeledLeft
- &&
-
- // me.Flags != MouseFlags.Button1Pressed && me.Flags != MouseFlags.Button1Clicked &&
- !me.Flags.HasFlag (MouseFlags.Button1Pressed | MouseFlags.ReportMousePosition))
- {
- return false;
- }
-
- if (me.Flags == MouseFlags.WheeledDown && ShowVerticalScrollIndicator)
- {
- ScrollDown (1);
- }
- else if (me.Flags == MouseFlags.WheeledUp && ShowVerticalScrollIndicator)
- {
- ScrollUp (1);
- }
- else if (me.Flags == MouseFlags.WheeledRight && _showHorizontalScrollIndicator)
- {
- ScrollRight (1);
- }
- else if (me.Flags == MouseFlags.WheeledLeft && ShowVerticalScrollIndicator)
- {
- ScrollLeft (1);
- }
- else if (me.X == _vertical.Frame.X && ShowVerticalScrollIndicator)
- {
- _vertical.MouseEvent (me);
- }
- else if (me.Y == _horizontal.Frame.Y && ShowHorizontalScrollIndicator)
- {
- _horizontal.MouseEvent (me);
- }
- else if (IsOverridden (me.View, "MouseEvent"))
- {
- Application.UngrabMouse ();
- }
-
- return true;
- }
-
///
public override void OnDrawContent (Rectangle contentArea)
{
@@ -429,6 +383,41 @@ public override bool OnKeyDown (Key a)
return false;
}
+ ///
+ protected internal override bool OnMouseEvent (MouseEvent me)
+ {
+ if (me.Flags == MouseFlags.WheeledDown && ShowVerticalScrollIndicator)
+ {
+ ScrollDown (1);
+ }
+ else if (me.Flags == MouseFlags.WheeledUp && ShowVerticalScrollIndicator)
+ {
+ ScrollUp (1);
+ }
+ else if (me.Flags == MouseFlags.WheeledRight && _showHorizontalScrollIndicator)
+ {
+ ScrollRight (1);
+ }
+ else if (me.Flags == MouseFlags.WheeledLeft && ShowVerticalScrollIndicator)
+ {
+ ScrollLeft (1);
+ }
+ else if (me.X == _vertical.Frame.X && ShowVerticalScrollIndicator)
+ {
+ _vertical.OnMouseEvent (me);
+ }
+ else if (me.Y == _horizontal.Frame.Y && ShowHorizontalScrollIndicator)
+ {
+ _horizontal.OnMouseEvent (me);
+ }
+ else if (IsOverridden (me.View, "OnMouseEvent"))
+ {
+ Application.UngrabMouse ();
+ }
+
+ return base.OnMouseEvent(me);
+ }
+
///
public override void PositionCursor ()
{
@@ -591,8 +580,8 @@ private void SetContentBottomRightCornerVisibility ()
private void SetContentOffset (Point offset)
{
// INTENT: Unclear intent. How about a call to Offset?
- _contentOffset = new (-Math.Abs (offset.X), -Math.Abs (offset.Y));
- _contentView.Frame = new (_contentOffset, _contentSize);
+ _contentOffset = new Point (-Math.Abs (offset.X), -Math.Abs (offset.Y));
+ _contentView.Frame = new Rectangle (_contentOffset, _contentSize);
int p = Math.Max (0, -_contentOffset.Y);
if (_vertical.Position != p)
diff --git a/Terminal.Gui/Views/Slider.cs b/Terminal.Gui/Views/Slider.cs
index 4e3aae25c3..7313d40068 100644
--- a/Terminal.Gui/Views/Slider.cs
+++ b/Terminal.Gui/Views/Slider.cs
@@ -1522,7 +1522,7 @@ private void DrawLegends ()
private Point? _moveRenderPosition;
///
- public override bool MouseEvent (MouseEvent mouseEvent)
+ protected internal override bool OnMouseEvent (MouseEvent mouseEvent)
{
// Note(jmperricone): Maybe we click to focus the cursor, and on next click we set the option.
// That will makes OptionFocused Event more relevant.
diff --git a/Terminal.Gui/Views/StatusBar.cs b/Terminal.Gui/Views/StatusBar.cs
index d4c7c03d4d..0dfe31cf11 100644
--- a/Terminal.Gui/Views/StatusBar.cs
+++ b/Terminal.Gui/Views/StatusBar.cs
@@ -142,7 +142,7 @@ public void AddItemAt (int index, StatusItem item)
}
///
- public override bool MouseEvent (MouseEvent me)
+ protected internal override bool OnMouseEvent (MouseEvent me)
{
if (me.Flags != MouseFlags.Button1Clicked)
{
diff --git a/Terminal.Gui/Views/TabView.cs b/Terminal.Gui/Views/TabView.cs
index a8874a1cc7..03838fbf24 100644
--- a/Terminal.Gui/Views/TabView.cs
+++ b/Terminal.Gui/Views/TabView.cs
@@ -533,7 +533,7 @@ private int GetTabHeight (bool top)
return Style.ShowTopLine ? 3 : 2;
}
- private void Tab_MouseClick (object sender, MouseEventEventArgs e) { e.Handled = _tabsBar.MouseEvent (e.MouseEvent); }
+ private void Tab_MouseClick (object sender, MouseEventEventArgs e) { e.Handled = _tabsBar.OnMouseEvent (e.MouseEvent); }
private void UnSetCurrentTabs ()
{
@@ -590,7 +590,7 @@ public TabRowView (TabView host)
Add (_rightScrollIndicator, _leftScrollIndicator);
}
- public override bool MouseEvent (MouseEvent me)
+ protected internal override bool OnMouseEvent (MouseEvent me)
{
Tab hit = me.View is Tab ? (Tab)me.View : null;
diff --git a/Terminal.Gui/Views/TableView/TableView.cs b/Terminal.Gui/Views/TableView/TableView.cs
index 2d906d9d6e..3525471681 100644
--- a/Terminal.Gui/Views/TableView/TableView.cs
+++ b/Terminal.Gui/Views/TableView/TableView.cs
@@ -787,7 +787,7 @@ public bool IsSelected (int col, int row)
}
///
- public override bool MouseEvent (MouseEvent me)
+ protected internal override bool OnMouseEvent (MouseEvent me)
{
if (!me.Flags.HasFlag (MouseFlags.Button1Clicked)
&& !me.Flags.HasFlag (MouseFlags.Button1DoubleClicked)
@@ -892,7 +892,7 @@ public override bool MouseEvent (MouseEvent me)
}
}
- return false;
+ return base.OnMouseEvent (me);
}
///
diff --git a/Terminal.Gui/Views/TextField.cs b/Terminal.Gui/Views/TextField.cs
index a99dacd7df..4b52b9f2e9 100644
--- a/Terminal.Gui/Views/TextField.cs
+++ b/Terminal.Gui/Views/TextField.cs
@@ -343,7 +343,7 @@ public TextField ()
// OnAccept returns true if the event is canceled.
// By Default pressing ENTER should be ignored (Invoke(Command.Accept) should return false).
- AddCommand (Command.Accept, () => OnAccept() != true);
+ AddCommand (Command.Accept, () => OnAccept () != true);
// Default keybindings for this view
// We follow this as closely as possible: https://en.wikipedia.org/wiki/Table_of_keyboard_shortcuts
@@ -846,7 +846,7 @@ public virtual void KillWordForwards ()
}
///
- public override bool MouseEvent (MouseEvent ev)
+ protected internal override bool OnMouseEvent (MouseEvent ev)
{
if (!ev.Flags.HasFlag (MouseFlags.Button1Pressed)
&& !ev.Flags.HasFlag (MouseFlags.ReportMousePosition)
@@ -855,7 +855,7 @@ public override bool MouseEvent (MouseEvent ev)
&& !ev.Flags.HasFlag (MouseFlags.Button1TripleClicked)
&& !ev.Flags.HasFlag (ContextMenu.MouseFlags))
{
- return false;
+ return base.OnMouseEvent (ev);
}
if (!CanFocus)
@@ -869,7 +869,7 @@ public override bool MouseEvent (MouseEvent ev)
}
// Give autocomplete first opportunity to respond to mouse clicks
- if (SelectedLength == 0 && Autocomplete.MouseEvent (ev, true))
+ if (SelectedLength == 0 && Autocomplete.OnMouseEvent (ev, true))
{
return true;
}
diff --git a/Terminal.Gui/Views/TextValidateField.cs b/Terminal.Gui/Views/TextValidateField.cs
index ae99aba046..a86cd910f5 100644
--- a/Terminal.Gui/Views/TextValidateField.cs
+++ b/Terminal.Gui/Views/TextValidateField.cs
@@ -533,7 +533,7 @@ public ITextValidateProvider Provider
}
///
- public override bool MouseEvent (MouseEvent mouseEvent)
+ protected internal override bool OnMouseEvent (MouseEvent mouseEvent)
{
if (mouseEvent.Flags.HasFlag (MouseFlags.Button1Pressed))
{
diff --git a/Terminal.Gui/Views/TextView.cs b/Terminal.Gui/Views/TextView.cs
index 64bbb709c7..a55e0d209f 100644
--- a/Terminal.Gui/Views/TextView.cs
+++ b/Terminal.Gui/Views/TextView.cs
@@ -3319,7 +3319,7 @@ public void Load (List> cellsList)
}
///
- public override bool MouseEvent (MouseEvent ev)
+ protected internal override bool OnMouseEvent (MouseEvent ev)
{
if (!ev.Flags.HasFlag (MouseFlags.Button1Clicked)
&& !ev.Flags.HasFlag (MouseFlags.Button1Pressed)
@@ -3349,7 +3349,7 @@ public override bool MouseEvent (MouseEvent ev)
_continuousFind = false;
// Give autocomplete first opportunity to respond to mouse clicks
- if (SelectedLength == 0 && Autocomplete.MouseEvent (ev, true))
+ if (SelectedLength == 0 && Autocomplete.OnMouseEvent (ev, true))
{
return true;
}
diff --git a/Terminal.Gui/Views/TileView.cs b/Terminal.Gui/Views/TileView.cs
index 4fbf2ff85d..086358ac2c 100644
--- a/Terminal.Gui/Views/TileView.cs
+++ b/Terminal.Gui/Views/TileView.cs
@@ -901,7 +901,7 @@ public void DrawSplitterSymbol ()
}
}
- public override bool MouseEvent (MouseEvent mouseEvent)
+ protected internal override bool OnMouseEvent (MouseEvent mouseEvent)
{
if (!dragPosition.HasValue && mouseEvent.Flags == MouseFlags.Button1Pressed)
{
diff --git a/Terminal.Gui/Views/TimeField.cs b/Terminal.Gui/Views/TimeField.cs
index 2779c2f838..367590d2fc 100644
--- a/Terminal.Gui/Views/TimeField.cs
+++ b/Terminal.Gui/Views/TimeField.cs
@@ -163,9 +163,9 @@ public override void DeleteCharRight ()
}
///
- public override bool MouseEvent (MouseEvent ev)
+ protected internal override bool OnMouseEvent (MouseEvent ev)
{
- bool result = base.MouseEvent (ev);
+ bool result = base.OnMouseEvent (ev);
if (result && SelectedLength == 0 && ev.Flags.HasFlag (MouseFlags.Button1Pressed))
{
diff --git a/Terminal.Gui/Views/Toplevel.cs b/Terminal.Gui/Views/Toplevel.cs
index 92d801e615..d4e7dd1a21 100644
--- a/Terminal.Gui/Views/Toplevel.cs
+++ b/Terminal.Gui/Views/Toplevel.cs
@@ -237,7 +237,7 @@ public override void Add (View view)
public event EventHandler Loaded;
///
- public override bool MouseEvent (MouseEvent mouseEvent)
+ protected internal override bool OnMouseEvent (MouseEvent mouseEvent)
{
if (!CanFocus)
{
diff --git a/Terminal.Gui/Views/TreeView/TreeView.cs b/Terminal.Gui/Views/TreeView/TreeView.cs
index 96b5941c83..941948737b 100644
--- a/Terminal.Gui/Views/TreeView/TreeView.cs
+++ b/Terminal.Gui/Views/TreeView/TreeView.cs
@@ -455,9 +455,10 @@ public void ClearObjects ()
/// if was fired.
public bool? ActivateSelectedObjectIfAny ()
{
+ // By default, Command.Accept calls OnAccept, so we need to call it here to ensure that the event is fired.
if (OnAccept () == true)
{
- return false;
+ return true;
}
T o = SelectedObject;
@@ -1001,7 +1002,7 @@ public void GoToFirst ()
public bool IsSelected (T model) { return Equals (SelectedObject, model) || (MultiSelect && multiSelectedRegions.Any (s => s.Contains (model))); }
///
- public override bool MouseEvent (MouseEvent me)
+ protected internal override bool OnMouseEvent (MouseEvent me)
{
// If it is not an event we care about
if (!me.Flags.HasFlag (MouseFlags.Button1Clicked)
@@ -1012,7 +1013,7 @@ public override bool MouseEvent (MouseEvent me)
&& !me.Flags.HasFlag (MouseFlags.WheeledLeft))
{
// do nothing
- return false;
+ return base.OnMouseEvent (me);
}
if (!HasFocus && CanFocus)
diff --git a/UICatalog/Scenarios/ASCIICustomButton.cs b/UICatalog/Scenarios/ASCIICustomButton.cs
index d9ee6e80da..c597b18d9f 100644
--- a/UICatalog/Scenarios/ASCIICustomButton.cs
+++ b/UICatalog/Scenarios/ASCIICustomButton.cs
@@ -126,31 +126,6 @@ public override bool OnLeave (View view)
return base.OnLeave (view);
}
- public override bool OnMouseEvent (MouseEvent mouseEvent)
- {
- Debug.WriteLine ($"{mouseEvent.Flags}");
-
- if (mouseEvent.Flags == MouseFlags.Button1Clicked)
- {
- if (!HasFocus && SuperView != null)
- {
- if (!SuperView.HasFocus)
- {
- SuperView.SetFocus ();
- }
-
- SetFocus ();
- SetNeedsDisplay ();
- }
-
- OnAccept ();
-
- return true;
- }
-
- return base.OnMouseEvent (mouseEvent);
- }
-
public event Action PointerEnter;
private void This_MouseClick (object sender, MouseEventEventArgs obj) { OnMouseEvent (obj.MouseEvent); }
}
diff --git a/UICatalog/Scenarios/LineDrawing.cs b/UICatalog/Scenarios/LineDrawing.cs
index 8399d020ba..d67e81384d 100644
--- a/UICatalog/Scenarios/LineDrawing.cs
+++ b/UICatalog/Scenarios/LineDrawing.cs
@@ -84,7 +84,7 @@ public override bool OnKeyDown (Key e)
return false;
}
- public override bool OnMouseEvent (MouseEvent mouseEvent)
+ protected override bool OnMouseEvent (MouseEvent mouseEvent)
{
if (mouseEvent.Flags.HasFlag (MouseFlags.Button1Pressed))
{
diff --git a/UnitTests/Application/KeyboardTests.cs b/UnitTests/Application/KeyboardTests.cs
index c0ea94343e..1d33f4a23d 100644
--- a/UnitTests/Application/KeyboardTests.cs
+++ b/UnitTests/Application/KeyboardTests.cs
@@ -172,13 +172,13 @@ public void EnsuresTopOnFront_CanFocus_False_By_Keyboard_And_Mouse ()
Assert.True (win2.HasFocus);
Assert.Equal ("win2", ((Window)top.Subviews [top.Subviews.Count - 1]).Title);
- win.MouseEvent (new MouseEvent { Flags = MouseFlags.Button1Pressed });
+ win.OnMouseEvent (new MouseEvent { Flags = MouseFlags.Button1Pressed });
Assert.False (win.CanFocus);
Assert.False (win.HasFocus);
Assert.True (win2.CanFocus);
Assert.True (win2.HasFocus);
Assert.Equal ("win2", ((Window)top.Subviews [top.Subviews.Count - 1]).Title);
- win2.MouseEvent (new MouseEvent { Flags = MouseFlags.Button1Released });
+ win2.OnMouseEvent (new MouseEvent { Flags = MouseFlags.Button1Released });
Assert.Null (Toplevel._dragPosition);
}
@@ -233,13 +233,13 @@ public void EnsuresTopOnFront_CanFocus_True_By_Keyboard_And_Mouse ()
Assert.False (win2.HasFocus);
Assert.Equal ("win", ((Window)top.Subviews [top.Subviews.Count - 1]).Title);
- win2.MouseEvent (new MouseEvent { Flags = MouseFlags.Button1Pressed });
+ win2.OnMouseEvent (new MouseEvent { Flags = MouseFlags.Button1Pressed });
Assert.True (win.CanFocus);
Assert.False (win.HasFocus);
Assert.True (win2.CanFocus);
Assert.True (win2.HasFocus);
Assert.Equal ("win2", ((Window)top.Subviews [top.Subviews.Count - 1]).Title);
- win2.MouseEvent (new MouseEvent { Flags = MouseFlags.Button1Released });
+ win2.OnMouseEvent (new MouseEvent { Flags = MouseFlags.Button1Released });
Assert.Null (Toplevel._dragPosition);
}
diff --git a/UnitTests/Application/MouseTests.cs b/UnitTests/Application/MouseTests.cs
index b52d0a2cd8..8c0791070f 100644
--- a/UnitTests/Application/MouseTests.cs
+++ b/UnitTests/Application/MouseTests.cs
@@ -60,11 +60,11 @@ void OnApplicationOnMouseEvent (object s, MouseEventEventArgs e)
}
///
- /// Tests that the mouse coordinates passed to the focused view are correct when the mouse is clicked. No frames;
+ /// Tests that the mouse coordinates passed to the focused view are correct when the mouse is clicked. No adornments;
/// Frame == Bounds
///
- [AutoInitShutdown]
[Theory]
+ [AutoInitShutdown]
// click inside view tests
[InlineData (0, 0, 0, 0, 0, true)]
@@ -94,7 +94,7 @@ void OnApplicationOnMouseEvent (object s, MouseEventEventArgs e)
[InlineData (1, 0, 1, 0, 0, false)]
[InlineData (1, 9, 0, 0, 0, false)]
[InlineData (1, 0, 9, 0, 0, false)]
- public void MouseCoordinatesTest_NoFrames (
+ public void MouseCoordinatesTest_NoAdornments (
int offset,
int clickX,
int clickY,
@@ -107,23 +107,27 @@ bool expectedClicked
Point pos = new (offset, offset);
var clicked = false;
- Application.Top.X = pos.X;
- Application.Top.Y = pos.Y;
- Application.Top.Width = size.Width;
- Application.Top.Height = size.Height;
-
- Application.Begin (Application.Top);
+ var view = new View ()
+ {
+ X = pos.X,
+ Y = pos.Y,
+ Width = size.Width,
+ Height = size.Height
+ };
+ view.BeginInit();
+ view.EndInit();
var mouseEvent = new MouseEvent { X = clickX, Y = clickY, Flags = MouseFlags.Button1Clicked };
var mouseEventArgs = new MouseEventEventArgs (mouseEvent);
- Application.Top.MouseClick += (s, e) =>
+ view.MouseClick += (s, e) =>
{
Assert.Equal (expectedX, e.MouseEvent.X);
Assert.Equal (expectedY, e.MouseEvent.Y);
clicked = true;
};
+ Application.Top.Add (view);
Application.OnMouseEvent (mouseEventArgs);
Assert.Equal (expectedClicked, clicked);
}
diff --git a/UnitTests/Dialogs/WizardTests.cs b/UnitTests/Dialogs/WizardTests.cs
index ede643c73c..e2c5c19f72 100644
--- a/UnitTests/Dialogs/WizardTests.cs
+++ b/UnitTests/Dialogs/WizardTests.cs
@@ -38,7 +38,7 @@ public void Finish_Button_Closes ()
var firstIteration = true;
Application.RunIteration (ref runstate, ref firstIteration);
- wizard.NextFinishButton.OnAccept ();
+ wizard.NextFinishButton.InvokeCommand (Command.Accept);
Application.RunIteration (ref runstate, ref firstIteration);
Application.End (runstate);
Assert.True (finishedFired);
@@ -64,13 +64,13 @@ public void Finish_Button_Closes ()
Application.RunIteration (ref runstate, ref firstIteration);
Assert.Equal (step1.Title, wizard.CurrentStep.Title);
- wizard.NextFinishButton.OnAccept ();
+ wizard.NextFinishButton.InvokeCommand (Command.Accept);
Assert.False (finishedFired);
Assert.False (closedFired);
Assert.Equal (step2.Title, wizard.CurrentStep.Title);
Assert.Equal (wizard.GetLastStep ().Title, wizard.CurrentStep.Title);
- wizard.NextFinishButton.OnAccept ();
+ wizard.NextFinishButton.InvokeCommand (Command.Accept);
Application.End (runstate);
Assert.True (finishedFired);
Assert.True (closedFired);
@@ -99,7 +99,7 @@ public void Finish_Button_Closes ()
Assert.Equal (step2.Title, wizard.CurrentStep.Title);
Assert.Equal (wizard.GetLastStep ().Title, wizard.CurrentStep.Title);
- wizard.NextFinishButton.OnAccept ();
+ wizard.NextFinishButton.InvokeCommand (Command.Accept);
Application.End (runstate);
Assert.True (finishedFired);
Assert.True (closedFired);
diff --git a/UnitTests/Input/ResponderTests.cs b/UnitTests/Input/ResponderTests.cs
index 5bed852579..5f5346aad4 100644
--- a/UnitTests/Input/ResponderTests.cs
+++ b/UnitTests/Input/ResponderTests.cs
@@ -113,28 +113,28 @@ void View_Disposing (object sender, EventArgs e)
public void IsOverridden_False_IfNotOverridden ()
{
// MouseEvent IS defined on Responder but NOT overridden
- Assert.False (Responder.IsOverridden (new Responder (), "MouseEvent"));
+ Assert.False (Responder.IsOverridden (new Responder (), "OnMouseEvent"));
// MouseEvent is defined on Responder and NOT overrident on View
Assert.False (
Responder.IsOverridden (
- new View { Text = "View does not override MouseEvent" },
- "MouseEvent"
+ new View { Text = "View does not override OnMouseEvent" },
+ "OnMouseEvent"
)
);
Assert.False (
Responder.IsOverridden (
- new DerivedView { Text = "DerivedView does not override MouseEvent" },
- "MouseEvent"
+ new DerivedView { Text = "DerivedView does not override OnMouseEvent" },
+ "OnMouseEvent"
)
);
// MouseEvent is NOT defined on DerivedView
Assert.False (
Responder.IsOverridden (
- new DerivedView { Text = "DerivedView does not override MouseEvent" },
- "MouseEvent"
+ new DerivedView { Text = "DerivedView does not override OnMouseEvent" },
+ "OnMouseEvent"
)
);
@@ -161,8 +161,8 @@ public void IsOverridden_True_IfOverridden ()
// MouseEvent is defined on Responder IS overriden on ScrollBarView (but not View)
Assert.True (
Responder.IsOverridden (
- new ScrollBarView { Text = "ScrollBarView overrides MouseEvent" },
- "MouseEvent"
+ new ScrollBarView { Text = "ScrollBarView overrides OnMouseEvent" },
+ "OnMouseEvent"
)
);
@@ -180,8 +180,8 @@ public void IsOverridden_True_IfOverridden ()
// ScrollBarView overrides both MouseEvent (from Responder) and Redraw (from View)
Assert.True (
Responder.IsOverridden (
- new ScrollBarView { Text = "ScrollBarView overrides MouseEvent" },
- "MouseEvent"
+ new ScrollBarView { Text = "ScrollBarView overrides OnMouseEvent" },
+ "OnMouseEvent"
)
);
@@ -191,13 +191,6 @@ public void IsOverridden_True_IfOverridden ()
"OnDrawContent"
)
);
-
- Assert.True (
- Responder.IsOverridden (
- new Button { Text = "Button overrides MouseEvent" },
- "MouseEvent"
- )
- );
#if DEBUG_IDISPOSABLE
// HACK: Force clean up of Responders to avoid having to Dispose all the Views created above.
@@ -245,7 +238,7 @@ public void New_Methods_Return_False ()
//Assert.False (r.OnKeyDown (new KeyEventArgs () { Key = Key.Unknown }));
Assert.False (r.OnKeyDown (new Key { KeyCode = KeyCode.Null }));
Assert.False (r.OnKeyUp (new Key { KeyCode = KeyCode.Null }));
- Assert.False (r.MouseEvent (new MouseEvent { Flags = MouseFlags.AllEvents }));
+ Assert.False (r.OnMouseEvent (new MouseEvent { Flags = MouseFlags.AllEvents }));
Assert.False (r.OnMouseEnter (new MouseEvent { Flags = MouseFlags.AllEvents }));
Assert.False (r.OnMouseLeave (new MouseEvent { Flags = MouseFlags.AllEvents }));
diff --git a/UnitTests/Text/AutocompleteTests.cs b/UnitTests/Text/AutocompleteTests.cs
index f44f48ca98..61ad0d023e 100644
--- a/UnitTests/Text/AutocompleteTests.cs
+++ b/UnitTests/Text/AutocompleteTests.cs
@@ -50,7 +50,7 @@ This a long line and against TextView.
}
Assert.True (
- tv.MouseEvent (
+ tv.OnMouseEvent (
new MouseEvent { X = 6, Y = 0, Flags = MouseFlags.Button1Pressed }
)
);
diff --git a/UnitTests/View/NavigationTests.cs b/UnitTests/View/NavigationTests.cs
index ac93b2b151..bb47034952 100644
--- a/UnitTests/View/NavigationTests.cs
+++ b/UnitTests/View/NavigationTests.cs
@@ -445,7 +445,7 @@ public void Enabled_False_Sets_HasFocus_To_False ()
view.NewKeyDownEvent (Key.Space);
Assert.True (wasClicked);
- view.MouseEvent (new MouseEvent { Flags = MouseFlags.Button1Clicked });
+ view.OnMouseEvent (new MouseEvent { Flags = MouseFlags.Button1Clicked });
Assert.False (wasClicked);
Assert.True (view.Enabled);
Assert.True (view.CanFocus);
@@ -454,7 +454,7 @@ public void Enabled_False_Sets_HasFocus_To_False ()
view.Enabled = false;
view.NewKeyDownEvent (Key.Space);
Assert.False (wasClicked);
- view.MouseEvent (new MouseEvent { Flags = MouseFlags.Button1Clicked });
+ view.OnMouseEvent (new MouseEvent { Flags = MouseFlags.Button1Clicked });
Assert.False (wasClicked);
Assert.False (view.Enabled);
Assert.True (view.CanFocus);
@@ -483,7 +483,7 @@ public void Enabled_Sets_Also_Sets_Subviews ()
win.NewKeyDownEvent (Key.Enter);
Assert.True (wasClicked);
- button.MouseEvent (new MouseEvent { Flags = MouseFlags.Button1Clicked });
+ button.OnMouseEvent (new MouseEvent { Flags = MouseFlags.Button1Clicked });
Assert.False (wasClicked);
Assert.True (button.Enabled);
Assert.True (button.CanFocus);
@@ -495,7 +495,7 @@ public void Enabled_Sets_Also_Sets_Subviews ()
win.Enabled = false;
button.NewKeyDownEvent (Key.Enter);
Assert.False (wasClicked);
- button.MouseEvent (new MouseEvent { Flags = MouseFlags.Button1Clicked });
+ button.OnMouseEvent (new MouseEvent { Flags = MouseFlags.Button1Clicked });
Assert.False (wasClicked);
Assert.False (button.Enabled);
Assert.True (button.CanFocus);
diff --git a/UnitTests/View/ViewTests.cs b/UnitTests/View/ViewTests.cs
index a5ef315b4a..c3e9755f30 100644
--- a/UnitTests/View/ViewTests.cs
+++ b/UnitTests/View/ViewTests.cs
@@ -840,7 +840,7 @@ public void New_Methods_Return_False ()
//Assert.False (r.OnKeyDown (new KeyEventArgs () { Key = Key.Unknown }));
Assert.False (r.OnKeyUp (new Key { KeyCode = KeyCode.Null }));
- Assert.False (r.MouseEvent (new MouseEvent { Flags = MouseFlags.AllEvents }));
+ Assert.False (r.OnMouseEvent (new MouseEvent { Flags = MouseFlags.AllEvents }));
Assert.False (r.OnMouseEnter (new MouseEvent { Flags = MouseFlags.AllEvents }));
Assert.False (r.OnMouseLeave (new MouseEvent { Flags = MouseFlags.AllEvents }));
@@ -1161,7 +1161,7 @@ public void OnAccept_Fires_Accept ()
view.Accept += ViewOnAccept;
- view.OnAccept ();
+ view.InvokeCommand (Command.Accept);
Assert.True (accepted);
return;
@@ -1176,7 +1176,7 @@ public void Accept_Cancel_Event_OnAccept_Returns_True ()
view.Accept += ViewOnAccept;
- var ret = view.OnAccept ();
+ var ret = view.InvokeCommand (Command.Accept);
Assert.True (ret);
Assert.True (acceptInvoked);
diff --git a/UnitTests/Views/ButtonTests.cs b/UnitTests/Views/ButtonTests.cs
index 4c5b5f9e8c..72d9e9cd34 100644
--- a/UnitTests/Views/ButtonTests.cs
+++ b/UnitTests/Views/ButtonTests.cs
@@ -693,7 +693,7 @@ public void Accept_Cancel_Event_OnAccept_Returns_True ()
button.Accept += ButtonAccept;
- var ret = button.OnAccept ();
+ var ret = button.InvokeCommand (Command.Accept);
Assert.True (ret);
Assert.True (acceptInvoked);
diff --git a/UnitTests/Views/CheckBoxTests.cs b/UnitTests/Views/CheckBoxTests.cs
index b0fca5a7e6..c7ce63e366 100644
--- a/UnitTests/Views/CheckBoxTests.cs
+++ b/UnitTests/Views/CheckBoxTests.cs
@@ -47,7 +47,7 @@ public void AllowNullChecked_Get_Set ()
Assert.False (checkBox.Checked);
Assert.True (checkBox.NewKeyDownEvent (Key.Space));
Assert.True (checkBox.Checked);
- Assert.True (checkBox.MouseEvent (new MouseEvent { X = 0, Y = 0, Flags = MouseFlags.Button1Clicked }));
+ Assert.True (checkBox.OnMouseEvent (new MouseEvent { X = 0, Y = 0, Flags = MouseFlags.Button1Clicked }));
Assert.False (checkBox.Checked);
checkBox.AllowNullChecked = true;
@@ -60,11 +60,11 @@ public void AllowNullChecked_Get_Set ()
{CM.Glyphs.NullChecked} Check this out 你",
_output
);
- Assert.True (checkBox.MouseEvent (new MouseEvent { X = 0, Y = 0, Flags = MouseFlags.Button1Clicked }));
+ Assert.True (checkBox.OnMouseEvent (new MouseEvent { X = 0, Y = 0, Flags = MouseFlags.Button1Clicked }));
Assert.True (checkBox.Checked);
Assert.True (checkBox.NewKeyDownEvent (Key.Space));
Assert.False (checkBox.Checked);
- Assert.True (checkBox.MouseEvent (new MouseEvent { X = 0, Y = 0, Flags = MouseFlags.Button1Clicked }));
+ Assert.True (checkBox.OnMouseEvent (new MouseEvent { X = 0, Y = 0, Flags = MouseFlags.Button1Clicked }));
Assert.Null (checkBox.Checked);
checkBox.AllowNullChecked = false;
@@ -328,7 +328,7 @@ public void Accept_Cancel_Event_OnAccept_Returns_True ()
ckb.Accept += ViewOnAccept;
- var ret = ckb.OnAccept ();
+ var ret = ckb.InvokeCommand (Command.Accept);
Assert.True (ret);
Assert.True (acceptInvoked);
@@ -567,13 +567,13 @@ public void HotKey_Command_Fires_Accept ()
var cb = new CheckBox ();
var accepted = false;
- cb.Accept += ButtonOnAccept;
+ cb.Accept += CheckBoxOnAccept;
cb.InvokeCommand (Command.HotKey);
Assert.True (accepted);
return;
- void ButtonOnAccept (object sender, CancelEventArgs e) { accepted = true; }
+ void CheckBoxOnAccept (object sender, CancelEventArgs e) { accepted = true; }
}
[Theory]
diff --git a/UnitTests/Views/ColorPickerTests.cs b/UnitTests/Views/ColorPickerTests.cs
index 2c1a48f1af..083110a7b9 100644
--- a/UnitTests/Views/ColorPickerTests.cs
+++ b/UnitTests/Views/ColorPickerTests.cs
@@ -51,9 +51,9 @@ public void MouseEvents ()
Application.Top.Add (colorPicker);
Application.Begin (Application.Top);
- Assert.False (colorPicker.MouseEvent (new MouseEvent ()));
+ Assert.False (colorPicker.OnMouseEvent (new MouseEvent ()));
- Assert.True (colorPicker.MouseEvent (new MouseEvent { Flags = MouseFlags.Button1Clicked, X = 4, Y = 1 }));
+ Assert.True (colorPicker.OnMouseEvent (new MouseEvent { Flags = MouseFlags.Button1Clicked, X = 4, Y = 1 }));
Assert.Equal (ColorName.Blue, colorPicker.SelectedColor);
}
diff --git a/UnitTests/Views/ComboBoxTests.cs b/UnitTests/Views/ComboBoxTests.cs
index cc582af01a..1a38b80d49 100644
--- a/UnitTests/Views/ComboBoxTests.cs
+++ b/UnitTests/Views/ComboBoxTests.cs
@@ -143,7 +143,7 @@ public void HideDropdownListOnClick_False_OpenSelectedItem_With_Mouse_And_Key_Cu
Assert.Equal ("", cb.Text);
Assert.True (
- cb.MouseEvent (
+ cb.OnMouseEvent (
new MouseEvent { X = cb.Bounds.Right - 1, Y = 0, Flags = MouseFlags.Button1Pressed }
)
);
@@ -199,7 +199,7 @@ public void HideDropdownListOnClick_False_OpenSelectedItem_With_Mouse_And_Key_F4
Assert.Equal ("", cb.Text);
Assert.True (
- cb.MouseEvent (
+ cb.OnMouseEvent (
new MouseEvent { X = cb.Bounds.Right - 1, Y = 0, Flags = MouseFlags.Button1Pressed }
)
);
@@ -235,7 +235,7 @@ public void
Assert.Equal ("", cb.Text);
Assert.True (
- cb.MouseEvent (
+ cb.OnMouseEvent (
new MouseEvent { X = cb.Bounds.Right - 1, Y = 0, Flags = MouseFlags.Button1Pressed }
)
);
@@ -291,7 +291,7 @@ public void HideDropdownListOnClick_Gets_Sets ()
Assert.Equal ("", cb.Text);
Assert.True (
- cb.MouseEvent (
+ cb.OnMouseEvent (
new MouseEvent { X = cb.Bounds.Right - 1, Y = 0, Flags = MouseFlags.Button1Pressed }
)
);
@@ -302,7 +302,7 @@ public void HideDropdownListOnClick_Gets_Sets ()
Assert.True (
cb.Subviews [1]
- .MouseEvent (
+ .OnMouseEvent (
new MouseEvent { X = 0, Y = 1, Flags = MouseFlags.Button1Clicked }
)
);
@@ -313,7 +313,7 @@ cb.Subviews [1]
Assert.True (
cb.Subviews [1]
- .MouseEvent (
+ .OnMouseEvent (
new MouseEvent { X = 0, Y = 1, Flags = MouseFlags.Button1Clicked }
)
);
@@ -326,7 +326,7 @@ cb.Subviews [1]
Assert.True (
cb.Subviews [1]
- .MouseEvent (
+ .OnMouseEvent (
new MouseEvent { X = 0, Y = 2, Flags = MouseFlags.Button1Clicked }
)
);
@@ -336,14 +336,14 @@ cb.Subviews [1]
Assert.Equal ("Three", cb.Text);
Assert.True (
- cb.MouseEvent (
+ cb.OnMouseEvent (
new MouseEvent { X = cb.Bounds.Right - 1, Y = 0, Flags = MouseFlags.Button1Pressed }
)
);
Assert.True (
cb.Subviews [1]
- .MouseEvent (
+ .OnMouseEvent (
new MouseEvent { X = 0, Y = 2, Flags = MouseFlags.Button1Clicked }
)
);
@@ -353,7 +353,7 @@ cb.Subviews [1]
Assert.Equal ("Three", cb.Text);
Assert.True (
- cb.MouseEvent (
+ cb.OnMouseEvent (
new MouseEvent { X = cb.Bounds.Right - 1, Y = 0, Flags = MouseFlags.Button1Pressed }
)
);
@@ -364,7 +364,7 @@ cb.Subviews [1]
Assert.True (
cb.Subviews [1]
- .MouseEvent (
+ .OnMouseEvent (
new MouseEvent { X = 0, Y = 0, Flags = MouseFlags.Button1Clicked }
)
);
@@ -391,14 +391,14 @@ public void HideDropdownListOnClick_True_Colapse_On_Click_Outside_Frame ()
Assert.Equal ("", cb.Text);
Assert.True (
- cb.MouseEvent (
+ cb.OnMouseEvent (
new MouseEvent { X = cb.Bounds.Right - 1, Y = 0, Flags = MouseFlags.Button1Pressed }
)
);
Assert.True (
cb.Subviews [1]
- .MouseEvent (
+ .OnMouseEvent (
new MouseEvent { X = cb.Bounds.Right - 1, Y = 0, Flags = MouseFlags.Button1Clicked }
)
);
@@ -409,7 +409,7 @@ cb.Subviews [1]
Assert.True (
cb.Subviews [1]
- .MouseEvent (
+ .OnMouseEvent (
new MouseEvent { X = -1, Y = 0, Flags = MouseFlags.Button1Clicked }
)
);
@@ -422,7 +422,7 @@ cb.Subviews [1]
Assert.True (
cb.Subviews [1]
- .MouseEvent (
+ .OnMouseEvent (
new MouseEvent { X = cb.Bounds.Right - 1, Y = 0, Flags = MouseFlags.Button1Clicked }
)
);
@@ -433,7 +433,7 @@ cb.Subviews [1]
Assert.True (
cb.Subviews [1]
- .MouseEvent (
+ .OnMouseEvent (
new MouseEvent { X = 0, Y = -1, Flags = MouseFlags.Button1Clicked }
)
);
@@ -446,7 +446,7 @@ cb.Subviews [1]
Assert.True (
cb.Subviews [1]
- .MouseEvent (
+ .OnMouseEvent (
new MouseEvent { X = cb.Bounds.Right - 1, Y = 0, Flags = MouseFlags.Button1Clicked }
)
);
@@ -457,7 +457,7 @@ cb.Subviews [1]
Assert.True (
cb.Subviews [1]
- .MouseEvent (
+ .OnMouseEvent (
new MouseEvent { X = cb.Frame.Width, Y = 0, Flags = MouseFlags.Button1Clicked }
)
);
@@ -470,7 +470,7 @@ cb.Subviews [1]
Assert.True (
cb.Subviews [1]
- .MouseEvent (
+ .OnMouseEvent (
new MouseEvent { X = cb.Bounds.Right - 1, Y = 0, Flags = MouseFlags.Button1Clicked }
)
);
@@ -481,7 +481,7 @@ cb.Subviews [1]
Assert.True (
cb.Subviews [1]
- .MouseEvent (
+ .OnMouseEvent (
new MouseEvent { X = 0, Y = cb.Frame.Height, Flags = MouseFlags.Button1Clicked }
)
);
@@ -508,7 +508,7 @@ public void HideDropdownListOnClick_True_Highlight_Current_Item ()
Assert.Equal ("", cb.Text);
Assert.True (
- cb.MouseEvent (
+ cb.OnMouseEvent (
new MouseEvent { X = cb.Bounds.Right - 1, Y = 0, Flags = MouseFlags.Button1Pressed }
)
);
@@ -664,7 +664,7 @@ public void HideDropdownListOnClick_True_OpenSelectedItem_With_Mouse_And_Key_And
Assert.Equal ("", cb.Text);
Assert.True (
- cb.MouseEvent (
+ cb.OnMouseEvent (
new MouseEvent { X = cb.Bounds.Right - 1, Y = 0, Flags = MouseFlags.Button1Pressed }
)
);
@@ -676,7 +676,7 @@ public void HideDropdownListOnClick_True_OpenSelectedItem_With_Mouse_And_Key_And
Assert.True (cb.Subviews [1].NewKeyDownEvent (Key.CursorDown));
Assert.True (
- cb.MouseEvent (
+ cb.OnMouseEvent (
new MouseEvent { X = cb.Bounds.Right - 1, Y = 0, Flags = MouseFlags.Button1Pressed }
)
);
@@ -686,7 +686,7 @@ public void HideDropdownListOnClick_True_OpenSelectedItem_With_Mouse_And_Key_And
Assert.Equal ("", cb.Text);
Assert.True (
- cb.MouseEvent (
+ cb.OnMouseEvent (
new MouseEvent { X = cb.Bounds.Right - 1, Y = 0, Flags = MouseFlags.Button1Pressed }
)
);
@@ -698,7 +698,7 @@ public void HideDropdownListOnClick_True_OpenSelectedItem_With_Mouse_And_Key_And
Assert.True (cb.Subviews [1].NewKeyDownEvent (Key.CursorUp));
Assert.True (
- cb.MouseEvent (
+ cb.OnMouseEvent (
new MouseEvent { X = cb.Bounds.Right - 1, Y = 0, Flags = MouseFlags.Button1Pressed }
)
);
@@ -725,7 +725,7 @@ public void HideDropdownListOnClick_True_OpenSelectedItem_With_Mouse_And_Key_Cur
Assert.Equal ("", cb.Text);
Assert.True (
- cb.MouseEvent (
+ cb.OnMouseEvent (
new MouseEvent { X = cb.Bounds.Right - 1, Y = 0, Flags = MouseFlags.Button1Pressed }
)
);
@@ -781,7 +781,7 @@ public void HideDropdownListOnClick_True_OpenSelectedItem_With_Mouse_And_Key_F4
Assert.Equal ("", cb.Text);
Assert.True (
- cb.MouseEvent (
+ cb.OnMouseEvent (
new MouseEvent { X = cb.Bounds.Right - 1, Y = 0, Flags = MouseFlags.Button1Pressed }
)
);
diff --git a/UnitTests/Views/ContextMenuTests.cs b/UnitTests/Views/ContextMenuTests.cs
index 3337f2ba35..115b085342 100644
--- a/UnitTests/Views/ContextMenuTests.cs
+++ b/UnitTests/Views/ContextMenuTests.cs
@@ -106,11 +106,11 @@ public void ContextMenu_Is_Closed_If_Another_MenuBar_Is_Open_Or_Vice_Versa ()
Assert.True (ContextMenu.IsShow);
Assert.Equal (cm.MenuBar, Application.MouseGrabView);
Assert.False (menu.IsMenuOpen);
- Assert.False (menu.MouseEvent (new MouseEvent { X = 1, Flags = MouseFlags.ReportMousePosition, View = menu }));
+ Assert.False (menu.OnMouseEvent (new MouseEvent { X = 1, Flags = MouseFlags.ReportMousePosition, View = menu }));
Assert.True (ContextMenu.IsShow);
Assert.Equal (cm.MenuBar, Application.MouseGrabView);
Assert.False (menu.IsMenuOpen);
- Assert.True (menu.MouseEvent (new MouseEvent { X = 1, Flags = MouseFlags.Button1Clicked, View = menu }));
+ Assert.True (menu.OnMouseEvent (new MouseEvent { X = 1, Flags = MouseFlags.Button1Clicked, View = menu }));
Assert.False (ContextMenu.IsShow);
Assert.Equal (menu, Application.MouseGrabView);
Assert.True (menu.IsMenuOpen);
@@ -642,7 +642,7 @@ public void Menus_And_SubMenus_Always_Try_To_Be_On_Screen ()
Assert.True (
top.Subviews [0]
- .MouseEvent (
+ .OnMouseEvent (
new MouseEvent { X = 0, Y = 4, Flags = MouseFlags.ReportMousePosition, View = top.Subviews [0] }
)
);
@@ -690,7 +690,7 @@ top.Subviews [0]
Assert.True (
top.Subviews [0]
- .MouseEvent (
+ .OnMouseEvent (
new MouseEvent { X = 30, Y = 4, Flags = MouseFlags.ReportMousePosition, View = top.Subviews [0] }
)
);
@@ -737,7 +737,7 @@ top.Subviews [0]
Assert.True (
top.Subviews [0]
- .MouseEvent (
+ .OnMouseEvent (
new MouseEvent { X = 30, Y = 4, Flags = MouseFlags.ReportMousePosition, View = top.Subviews [0] }
)
);
@@ -781,7 +781,7 @@ top.Subviews [0]
Assert.True (
top.Subviews [0]
- .MouseEvent (
+ .OnMouseEvent (
new MouseEvent { X = 30, Y = 4, Flags = MouseFlags.ReportMousePosition, View = top.Subviews [0] }
)
);
@@ -825,7 +825,7 @@ top.Subviews [0]
Assert.True (
top.Subviews [0]
- .MouseEvent (
+ .OnMouseEvent (
new MouseEvent { X = 30, Y = 4, Flags = MouseFlags.ReportMousePosition, View = top.Subviews [0] }
)
);
diff --git a/UnitTests/Views/ListViewTests.cs b/UnitTests/Views/ListViewTests.cs
index df976a2083..8acd233af4 100644
--- a/UnitTests/Views/ListViewTests.cs
+++ b/UnitTests/Views/ListViewTests.cs
@@ -713,7 +713,7 @@ public void Render (
//│Three│
//└─────┘", output);
- // Assert.True (lv.MouseEvent (new MouseEvent {
+ // Assert.True (lv.OnMouseEvent (new MouseEvent {
// X = 0,
// Y = 0,
// Flags = MouseFlags.Button1Clicked
@@ -721,7 +721,7 @@ public void Render (
// Assert.Equal ("", selected);
// Assert.Equal (-1, lv.SelectedItem);
- // Assert.True (lv.MouseEvent (new MouseEvent {
+ // Assert.True (lv.OnMouseEvent (new MouseEvent {
// X = 0,
// Y = 1,
// Flags = MouseFlags.Button1Clicked
@@ -729,7 +729,7 @@ public void Render (
// Assert.Equal ("One", selected);
// Assert.Equal (0, lv.SelectedItem);
- // Assert.True (lv.MouseEvent (new MouseEvent {
+ // Assert.True (lv.OnMouseEvent (new MouseEvent {
// X = 0,
// Y = 2,
// Flags = MouseFlags.Button1Clicked
@@ -737,7 +737,7 @@ public void Render (
// Assert.Equal ("Two", selected);
// Assert.Equal (1, lv.SelectedItem);
- // Assert.True (lv.MouseEvent (new MouseEvent {
+ // Assert.True (lv.OnMouseEvent (new MouseEvent {
// X = 0,
// Y = 3,
// Flags = MouseFlags.Button1Clicked
@@ -745,7 +745,7 @@ public void Render (
// Assert.Equal ("Three", selected);
// Assert.Equal (2, lv.SelectedItem);
- // Assert.True (lv.MouseEvent (new MouseEvent {
+ // Assert.True (lv.OnMouseEvent (new MouseEvent {
// X = 0,
// Y = 4,
// Flags = MouseFlags.Button1Clicked
diff --git a/UnitTests/Views/MenuBarTests.cs b/UnitTests/Views/MenuBarTests.cs
index aa014591a6..38f6594cba 100644
--- a/UnitTests/Views/MenuBarTests.cs
+++ b/UnitTests/Views/MenuBarTests.cs
@@ -37,13 +37,13 @@ public void AllowNullChecked_Get_Set ()
Assert.True (mi.Checked);
Assert.True (
- menu.MouseEvent (
+ menu.OnMouseEvent (
new MouseEvent { X = 0, Y = 0, Flags = MouseFlags.Button1Pressed, View = menu }
)
);
Assert.True (
- menu._openMenu.MouseEvent (
+ menu._openMenu.OnMouseEvent (
new MouseEvent { X = 0, Y = 1, Flags = MouseFlags.Button1Clicked, View = menu._openMenu }
)
);
@@ -57,7 +57,7 @@ public void AllowNullChecked_Get_Set ()
Assert.Null (mi.Checked);
Assert.True (
- menu.MouseEvent (
+ menu.OnMouseEvent (
new MouseEvent { X = 0, Y = 0, Flags = MouseFlags.Button1Pressed, View = menu }
)
);
@@ -75,7 +75,7 @@ Nullable Checked
);
Assert.True (
- menu._openMenu.MouseEvent (
+ menu._openMenu.OnMouseEvent (
new MouseEvent { X = 0, Y = 1, Flags = MouseFlags.Button1Clicked, View = menu._openMenu }
)
);
@@ -87,13 +87,13 @@ Nullable Checked
Assert.False (mi.Checked);
Assert.True (
- menu.MouseEvent (
+ menu.OnMouseEvent (
new MouseEvent { X = 0, Y = 0, Flags = MouseFlags.Button1Pressed, View = menu }
)
);
Assert.True (
- menu._openMenu.MouseEvent (
+ menu._openMenu.OnMouseEvent (
new MouseEvent { X = 0, Y = 1, Flags = MouseFlags.Button1Clicked, View = menu._openMenu }
)
);
@@ -296,7 +296,7 @@ public void Disabled_MenuItem_Is_Never_Selected ()
);
Assert.True (
- menu.MouseEvent (
+ menu.OnMouseEvent (
new MouseEvent { X = 0, Y = 0, Flags = MouseFlags.Button1Pressed, View = menu }
)
);
@@ -317,7 +317,7 @@ public void Disabled_MenuItem_Is_Never_Selected ()
Assert.True (
top.Subviews [1]
- .MouseEvent (
+ .OnMouseEvent (
new MouseEvent { X = 0, Y = 2, Flags = MouseFlags.Button1Clicked, View = top.Subviews [1] }
)
);
@@ -338,7 +338,7 @@ top.Subviews [1]
Assert.True (
top.Subviews [1]
- .MouseEvent (
+ .OnMouseEvent (
new MouseEvent { X = 0, Y = 2, Flags = MouseFlags.ReportMousePosition, View = top.Subviews [1] }
)
);
@@ -1460,13 +1460,13 @@ .Children [0]
Application.Top.Add (menu);
Application.Begin (Application.Top);
- Assert.True (menu.MouseEvent (new MouseEvent { X = 1, Y = 0, Flags = MouseFlags.Button1Pressed, View = menu }));
+ Assert.True (menu.OnMouseEvent (new MouseEvent { X = 1, Y = 0, Flags = MouseFlags.Button1Pressed, View = menu }));
Assert.True (menu.IsMenuOpen);
Application.Top.Draw ();
TestHelpers.AssertDriverContentsAre (expectedMenu.ExpectedSubMenuOpen (0), _output);
- Assert.True (menu.MouseEvent (new MouseEvent { X = 1, Y = 0, Flags = MouseFlags.Button1Pressed, View = menu }));
+ Assert.True (menu.OnMouseEvent (new MouseEvent { X = 1, Y = 0, Flags = MouseFlags.Button1Pressed, View = menu }));
Assert.False (menu.IsMenuOpen);
Application.Top.Draw ();
TestHelpers.AssertDriverContentsAre (expectedMenu.ClosedMenuText, _output);
@@ -2171,7 +2171,7 @@ public void MenuOpened_On_Disabled_MenuItem ()
// open the menu
Assert.True (
- menu.MouseEvent (
+ menu.OnMouseEvent (
new MouseEvent { X = 1, Y = 0, Flags = MouseFlags.Button1Pressed, View = menu }
)
);
@@ -2180,7 +2180,7 @@ public void MenuOpened_On_Disabled_MenuItem ()
Assert.Equal ("_New", miCurrent.Title);
Assert.True (
- mCurrent.MouseEvent (
+ mCurrent.OnMouseEvent (
new MouseEvent { X = 1, Y = 1, Flags = MouseFlags.ReportMousePosition, View = mCurrent }
)
);
@@ -2189,7 +2189,7 @@ public void MenuOpened_On_Disabled_MenuItem ()
Assert.Equal ("_New", miCurrent.Title);
Assert.True (
- mCurrent.MouseEvent (
+ mCurrent.OnMouseEvent (
new MouseEvent { X = 1, Y = 2, Flags = MouseFlags.ReportMousePosition, View = mCurrent }
)
);
@@ -2198,7 +2198,7 @@ public void MenuOpened_On_Disabled_MenuItem ()
Assert.Equal ("_New", miCurrent.Title);
Assert.True (
- mCurrent.MouseEvent (
+ mCurrent.OnMouseEvent (
new MouseEvent { X = 1, Y = 3, Flags = MouseFlags.ReportMousePosition, View = mCurrent }
)
);
@@ -2208,7 +2208,7 @@ public void MenuOpened_On_Disabled_MenuItem ()
// close the menu
Assert.True (
- menu.MouseEvent (
+ menu.OnMouseEvent (
new MouseEvent { X = 1, Y = 0, Flags = MouseFlags.Button1Pressed, View = menu }
)
);
@@ -2373,7 +2373,7 @@ public void MouseEvent_Test ()
Application.Begin (Application.Top);
Assert.True (
- menu.MouseEvent (
+ menu.OnMouseEvent (
new MouseEvent { X = 10, Y = 0, Flags = MouseFlags.Button1Pressed, View = menu }
)
);
@@ -2382,7 +2382,7 @@ public void MouseEvent_Test ()
Assert.Equal ("_Copy", miCurrent.Title);
Assert.True (
- mCurrent.MouseEvent (
+ mCurrent.OnMouseEvent (
new MouseEvent { X = 10, Y = 3, Flags = MouseFlags.ReportMousePosition, View = mCurrent }
)
);
@@ -2395,7 +2395,7 @@ public void MouseEvent_Test ()
if (i == -1)
{
Assert.False (
- mCurrent.MouseEvent (
+ mCurrent.OnMouseEvent (
new MouseEvent { X = 10, Y = i, Flags = MouseFlags.ReportMousePosition, View = menu }
)
);
@@ -2403,7 +2403,7 @@ public void MouseEvent_Test ()
else
{
Assert.True (
- mCurrent.MouseEvent (
+ mCurrent.OnMouseEvent (
new MouseEvent { X = 10, Y = i, Flags = MouseFlags.ReportMousePosition, View = mCurrent }
)
);
@@ -2564,14 +2564,14 @@ public void Parent_MenuItem_Stay_Focused_If_Child_MenuItem_Is_Empty_By_Mouse ()
Application.Begin (Application.Top);
Assert.True (tf.HasFocus);
- Assert.True (menu.MouseEvent (new MouseEvent { X = 1, Y = 0, Flags = MouseFlags.Button1Pressed, View = menu }));
+ Assert.True (menu.OnMouseEvent (new MouseEvent { X = 1, Y = 0, Flags = MouseFlags.Button1Pressed, View = menu }));
Assert.True (menu.IsMenuOpen);
Assert.False (tf.HasFocus);
Application.Top.Draw ();
TestHelpers.AssertDriverContentsAre (expectedMenu.ExpectedSubMenuOpen (0), _output);
Assert.True (
- menu.MouseEvent (
+ menu.OnMouseEvent (
new MouseEvent { X = 8, Y = 0, Flags = MouseFlags.ReportMousePosition, View = menu }
)
);
@@ -2581,7 +2581,7 @@ public void Parent_MenuItem_Stay_Focused_If_Child_MenuItem_Is_Empty_By_Mouse ()
TestHelpers.AssertDriverContentsAre (expectedMenu.ExpectedSubMenuOpen (1), _output);
Assert.True (
- menu.MouseEvent (
+ menu.OnMouseEvent (
new MouseEvent { X = 15, Y = 0, Flags = MouseFlags.ReportMousePosition, View = menu }
)
);
@@ -2591,7 +2591,7 @@ public void Parent_MenuItem_Stay_Focused_If_Child_MenuItem_Is_Empty_By_Mouse ()
TestHelpers.AssertDriverContentsAre (expectedMenu.ExpectedSubMenuOpen (2), _output);
Assert.True (
- menu.MouseEvent (
+ menu.OnMouseEvent (
new MouseEvent { X = 8, Y = 0, Flags = MouseFlags.ReportMousePosition, View = menu }
)
);
@@ -2601,7 +2601,7 @@ public void Parent_MenuItem_Stay_Focused_If_Child_MenuItem_Is_Empty_By_Mouse ()
TestHelpers.AssertDriverContentsAre (expectedMenu.ClosedMenuText, _output);
Assert.True (
- menu.MouseEvent (
+ menu.OnMouseEvent (
new MouseEvent { X = 1, Y = 0, Flags = MouseFlags.ReportMousePosition, View = menu }
)
);
@@ -2610,7 +2610,7 @@ public void Parent_MenuItem_Stay_Focused_If_Child_MenuItem_Is_Empty_By_Mouse ()
Application.Top.Draw ();
TestHelpers.AssertDriverContentsAre (expectedMenu.ExpectedSubMenuOpen (0), _output);
- Assert.True (menu.MouseEvent (new MouseEvent { X = 8, Y = 0, Flags = MouseFlags.Button1Pressed, View = menu }));
+ Assert.True (menu.OnMouseEvent (new MouseEvent { X = 8, Y = 0, Flags = MouseFlags.Button1Pressed, View = menu }));
Assert.False (menu.IsMenuOpen);
Assert.True (tf.HasFocus);
Application.Top.Draw ();
@@ -2939,7 +2939,7 @@ public void UseSubMenusSingleFrame_False_By_Mouse ()
Assert.Equal (new Rectangle (1, 0, 8, 1), pos);
Assert.True (
- menu.MouseEvent (
+ menu.OnMouseEvent (
new MouseEvent { X = 1, Y = 0, Flags = MouseFlags.Button1Pressed, View = menu }
)
);
@@ -2958,7 +2958,7 @@ public void UseSubMenusSingleFrame_False_By_Mouse ()
Assert.Equal (new Rectangle (1, 0, 10, 6), pos);
Assert.False (
- menu.MouseEvent (
+ menu.OnMouseEvent (
new MouseEvent
{
X = 1, Y = 3, Flags = MouseFlags.ReportMousePosition, View = Application.Top.Subviews [1]
@@ -2981,7 +2981,7 @@ public void UseSubMenusSingleFrame_False_By_Mouse ()
Assert.Equal (new Rectangle (1, 0, 25, 7), pos);
Assert.False (
- menu.MouseEvent (
+ menu.OnMouseEvent (
new MouseEvent
{
X = 1, Y = 2, Flags = MouseFlags.ReportMousePosition, View = Application.Top.Subviews [1]
@@ -3003,7 +3003,7 @@ public void UseSubMenusSingleFrame_False_By_Mouse ()
Assert.Equal (new Rectangle (1, 0, 10, 6), pos);
Assert.False (
- menu.MouseEvent (
+ menu.OnMouseEvent (
new MouseEvent { X = 70, Y = 2, Flags = MouseFlags.Button1Clicked, View = Application.Top }
)
);
@@ -3246,7 +3246,7 @@ public void UseSubMenusSingleFrame_True_By_Mouse ()
Assert.Equal (new Rectangle (1, 0, 8, 1), pos);
Assert.True (
- menu.MouseEvent (
+ menu.OnMouseEvent (
new MouseEvent { X = 1, Y = 0, Flags = MouseFlags.Button1Pressed, View = menu }
)
);
@@ -3265,7 +3265,7 @@ public void UseSubMenusSingleFrame_True_By_Mouse ()
Assert.Equal (new Rectangle (1, 0, 10, 6), pos);
Assert.False (
- menu.MouseEvent (
+ menu.OnMouseEvent (
new MouseEvent { X = 1, Y = 3, Flags = MouseFlags.Button1Clicked, View = Application.Top.Subviews [1] }
)
);
@@ -3285,7 +3285,7 @@ public void UseSubMenusSingleFrame_True_By_Mouse ()
Assert.Equal (new Rectangle (1, 0, 15, 7), pos);
Assert.False (
- menu.MouseEvent (
+ menu.OnMouseEvent (
new MouseEvent { X = 1, Y = 2, Flags = MouseFlags.Button1Clicked, View = Application.Top.Subviews [2] }
)
);
@@ -3304,7 +3304,7 @@ public void UseSubMenusSingleFrame_True_By_Mouse ()
Assert.Equal (new Rectangle (1, 0, 10, 6), pos);
Assert.False (
- menu.MouseEvent (
+ menu.OnMouseEvent (
new MouseEvent { X = 70, Y = 2, Flags = MouseFlags.Button1Clicked, View = Application.Top }
)
);
@@ -3440,7 +3440,7 @@ public void UseSubMenusSingleFrame_True_Without_Border ()
Assert.Equal (new Rectangle (1, 0, 8, 1), pos);
Assert.True (
- menu.MouseEvent (
+ menu.OnMouseEvent (
new MouseEvent { X = 1, Y = 0, Flags = MouseFlags.Button1Pressed, View = menu }
)
);
@@ -3457,7 +3457,7 @@ public void UseSubMenusSingleFrame_True_Without_Border ()
Assert.Equal (new Rectangle (1, 0, 8, 4), pos);
Assert.False (
- menu.MouseEvent (
+ menu.OnMouseEvent (
new MouseEvent { X = 1, Y = 2, Flags = MouseFlags.Button1Clicked, View = Application.Top.Subviews [1] }
)
);
@@ -3475,7 +3475,7 @@ public void UseSubMenusSingleFrame_True_Without_Border ()
Assert.Equal (new Rectangle (1, 0, 13, 5), pos);
Assert.False (
- menu.MouseEvent (
+ menu.OnMouseEvent (
new MouseEvent { X = 1, Y = 1, Flags = MouseFlags.Button1Clicked, View = Application.Top.Subviews [2] }
)
);
@@ -3492,7 +3492,7 @@ public void UseSubMenusSingleFrame_True_Without_Border ()
Assert.Equal (new Rectangle (1, 0, 8, 4), pos);
Assert.False (
- menu.MouseEvent (
+ menu.OnMouseEvent (
new MouseEvent { X = 70, Y = 2, Flags = MouseFlags.Button1Clicked, View = Application.Top }
)
);
diff --git a/UnitTests/Views/StatusBarTests.cs b/UnitTests/Views/StatusBarTests.cs
index d72c781488..1deb7a0be8 100644
--- a/UnitTests/Views/StatusBarTests.cs
+++ b/UnitTests/Views/StatusBarTests.cs
@@ -163,7 +163,7 @@ public void Run_Action_With_Key_And_Mouse ()
{
Assert.Equal ("Quiting...", msg);
msg = "";
- sb.MouseEvent (new MouseEvent { X = 1, Y = 24, Flags = MouseFlags.Button1Clicked });
+ sb.OnMouseEvent (new MouseEvent { X = 1, Y = 24, Flags = MouseFlags.Button1Clicked });
}
else
{
diff --git a/UnitTests/Views/TableViewTests.cs b/UnitTests/Views/TableViewTests.cs
index 5a7baf2771..b90f42b116 100644
--- a/UnitTests/Views/TableViewTests.cs
+++ b/UnitTests/Views/TableViewTests.cs
@@ -2190,7 +2190,7 @@ public void TestControlClick_MultiSelect_ThreeRowTable_FullRowSelect ()
tv.MultiSelect = true;
// Clicking in bottom row
- tv.MouseEvent (
+ tv.OnMouseEvent (
new MouseEvent { X = 1, Y = 4, Flags = MouseFlags.Button1Clicked }
);
@@ -2198,7 +2198,7 @@ public void TestControlClick_MultiSelect_ThreeRowTable_FullRowSelect ()
Assert.Equal (2, tv.SelectedRow);
// shift clicking top row
- tv.MouseEvent (
+ tv.OnMouseEvent (
new MouseEvent { X = 1, Y = 2, Flags = MouseFlags.Button1Clicked | MouseFlags.ButtonCtrl }
);
@@ -2262,7 +2262,7 @@ public void TestFullRowSelect_AlwaysUseNormalColorForVerticalCellLines ()
tv.Style.AlwaysUseNormalColorForVerticalCellLines = true;
// Clicking in bottom row
- tv.MouseEvent (
+ tv.OnMouseEvent (
new MouseEvent { X = 1, Y = 4, Flags = MouseFlags.Button1Clicked }
);
@@ -2317,7 +2317,7 @@ public void TestFullRowSelect_SelectionColorDoesNotStop_WhenShowVerticalCellLine
tv.Style.ShowVerticalHeaderLines = false;
// Clicking in bottom row
- tv.MouseEvent (
+ tv.OnMouseEvent (
new MouseEvent { X = 1, Y = 4, Flags = MouseFlags.Button1Clicked }
);
@@ -2370,7 +2370,7 @@ public void TestFullRowSelect_SelectionColorStopsAtTableEdge_WithCellLines ()
tv.Style.ShowHorizontalBottomline = true;
// Clicking in bottom row
- tv.MouseEvent (
+ tv.OnMouseEvent (
new MouseEvent { X = 1, Y = 4, Flags = MouseFlags.Button1Clicked }
);
@@ -2551,7 +2551,7 @@ public void TestShiftClick_MultiSelect_TwoRowTable_FullRowSelect ()
tv.MultiSelect = true;
// Clicking in bottom row
- tv.MouseEvent (
+ tv.OnMouseEvent (
new MouseEvent { X = 1, Y = 3, Flags = MouseFlags.Button1Clicked }
);
@@ -2559,7 +2559,7 @@ public void TestShiftClick_MultiSelect_TwoRowTable_FullRowSelect ()
Assert.Equal (1, tv.SelectedRow);
// shift clicking top row
- tv.MouseEvent (
+ tv.OnMouseEvent (
new MouseEvent { X = 1, Y = 2, Flags = MouseFlags.Button1Clicked | MouseFlags.ButtonShift }
);
diff --git a/UnitTests/Views/TextFieldTests.cs b/UnitTests/Views/TextFieldTests.cs
index cd6cc88c61..413973ac00 100644
--- a/UnitTests/Views/TextFieldTests.cs
+++ b/UnitTests/Views/TextFieldTests.cs
@@ -121,7 +121,7 @@ public void CanFocus_False_Wont_Focus_With_Mouse ()
Assert.False (fv.CanFocus);
Assert.False (fv.HasFocus);
- tf.MouseEvent (
+ tf.OnMouseEvent (
new MouseEvent { X = 1, Y = 0, Flags = MouseFlags.Button1DoubleClicked }
);
@@ -135,7 +135,7 @@ public void CanFocus_False_Wont_Focus_With_Mouse ()
fv.CanFocus = true;
tf.CanFocus = true;
- tf.MouseEvent (
+ tf.OnMouseEvent (
new MouseEvent { X = 1, Y = 0, Flags = MouseFlags.Button1DoubleClicked }
);
@@ -147,7 +147,7 @@ public void CanFocus_False_Wont_Focus_With_Mouse ()
fv.CanFocus = false;
- tf.MouseEvent (
+ tf.OnMouseEvent (
new MouseEvent { X = 1, Y = 0, Flags = MouseFlags.Button1DoubleClicked }
);
@@ -482,7 +482,7 @@ public void DeleteSelectedText_InsertText_DeleteCharLeft_DeleteCharRight_Cut ()
tf.Text = "Les Misérables movie.";
Assert.True (
- tf.MouseEvent (
+ tf.OnMouseEvent (
new MouseEvent { X = 7, Y = 1, Flags = MouseFlags.Button1DoubleClicked, View = tf }
)
);
@@ -1147,12 +1147,12 @@ public void SpaceHandling ()
var ev = new MouseEvent { X = 0, Y = 0, Flags = MouseFlags.Button1DoubleClicked };
- tf.MouseEvent (ev);
+ tf.OnMouseEvent (ev);
Assert.Equal (1, tf.SelectedLength);
ev = new MouseEvent { X = 1, Y = 0, Flags = MouseFlags.Button1DoubleClicked };
- tf.MouseEvent (ev);
+ tf.OnMouseEvent (ev);
Assert.Equal (1, tf.SelectedLength);
}
@@ -1532,14 +1532,14 @@ public void WordBackward_WordForward_SelectedText_With_Accent ()
Assert.Equal ("m", runes [idx].ToString ());
Assert.True (
- tf.MouseEvent (
+ tf.OnMouseEvent (
new MouseEvent { X = idx, Y = 1, Flags = MouseFlags.Button1DoubleClicked, View = tf }
)
);
Assert.Equal ("movie.", tf.SelectedText);
Assert.True (
- tf.MouseEvent (
+ tf.OnMouseEvent (
new MouseEvent { X = idx + 1, Y = 1, Flags = MouseFlags.Button1DoubleClicked, View = tf }
)
);
diff --git a/UnitTests/Views/TextValidateFieldTests.cs b/UnitTests/Views/TextValidateFieldTests.cs
index 162172ce57..981c83a279 100644
--- a/UnitTests/Views/TextValidateFieldTests.cs
+++ b/UnitTests/Views/TextValidateFieldTests.cs
@@ -322,7 +322,7 @@ public void MouseClick_Right_X_Greater_Than_Text_Width_Goes_To_Last_Editable_Pos
Assert.False (field.IsValid);
Assert.Equal ("--(1 )--", field.Provider.Text);
- field.MouseEvent (new MouseEvent { X = 25, Flags = MouseFlags.Button1Pressed });
+ field.OnMouseEvent (new MouseEvent { X = 25, Flags = MouseFlags.Button1Pressed });
field.NewKeyDownEvent (Key.D1);
diff --git a/UnitTests/Views/TextViewTests.cs b/UnitTests/Views/TextViewTests.cs
index 68421509ca..fdbe0e789b 100644
--- a/UnitTests/Views/TextViewTests.cs
+++ b/UnitTests/Views/TextViewTests.cs
@@ -159,7 +159,7 @@ public void CanFocus_False_Wont_Focus_With_Mouse ()
Assert.False (fv.CanFocus);
Assert.False (fv.HasFocus);
- tv.MouseEvent (new MouseEvent { X = 1, Y = 0, Flags = MouseFlags.Button1DoubleClicked });
+ tv.OnMouseEvent (new MouseEvent { X = 1, Y = 0, Flags = MouseFlags.Button1DoubleClicked });
Assert.Empty (tv.SelectedText);
Assert.False (tv.CanFocus);
@@ -170,7 +170,7 @@ public void CanFocus_False_Wont_Focus_With_Mouse ()
Assert.Throws (() => tv.CanFocus = true);
fv.CanFocus = true;
tv.CanFocus = true;
- tv.MouseEvent (new MouseEvent { X = 1, Y = 0, Flags = MouseFlags.Button1DoubleClicked });
+ tv.OnMouseEvent (new MouseEvent { X = 1, Y = 0, Flags = MouseFlags.Button1DoubleClicked });
Assert.Equal ("some ", tv.SelectedText);
Assert.True (tv.CanFocus);
@@ -179,7 +179,7 @@ public void CanFocus_False_Wont_Focus_With_Mouse ()
Assert.True (fv.HasFocus);
fv.CanFocus = false;
- tv.MouseEvent (new MouseEvent { X = 1, Y = 0, Flags = MouseFlags.Button1DoubleClicked });
+ tv.OnMouseEvent (new MouseEvent { X = 1, Y = 0, Flags = MouseFlags.Button1DoubleClicked });
Assert.Equal ("some ", tv.SelectedText); // Setting CanFocus to false don't change the SelectedText
Assert.False (tv.CanFocus);
@@ -1064,7 +1064,7 @@ public void DesiredCursorVisibility_Horizontal_Navigation ()
for (var i = 0; i < 12; i++)
{
- tv.MouseEvent (new MouseEvent { Flags = MouseFlags.WheeledRight });
+ tv.OnMouseEvent (new MouseEvent { Flags = MouseFlags.WheeledRight });
tv.PositionCursor ();
Assert.Equal (Math.Min (i + 1, 11), tv.LeftColumn);
Assert.Equal (CursorVisibility.Invisible, tv.DesiredCursorVisibility);
@@ -1072,7 +1072,7 @@ public void DesiredCursorVisibility_Horizontal_Navigation ()
for (var i = 11; i > 0; i--)
{
- tv.MouseEvent (new MouseEvent { Flags = MouseFlags.WheeledLeft });
+ tv.OnMouseEvent (new MouseEvent { Flags = MouseFlags.WheeledLeft });
tv.PositionCursor ();
Assert.Equal (i - 1, tv.LeftColumn);
@@ -1107,7 +1107,7 @@ public void DesiredCursorVisibility_Vertical_Navigation ()
for (var i = 0; i < 12; i++)
{
- tv.MouseEvent (new MouseEvent { Flags = MouseFlags.WheeledDown });
+ tv.OnMouseEvent (new MouseEvent { Flags = MouseFlags.WheeledDown });
tv.PositionCursor ();
Assert.Equal (i + 1, tv.TopRow);
Assert.Equal (CursorVisibility.Invisible, tv.DesiredCursorVisibility);
@@ -1115,7 +1115,7 @@ public void DesiredCursorVisibility_Vertical_Navigation ()
for (var i = 12; i > 0; i--)
{
- tv.MouseEvent (new MouseEvent { Flags = MouseFlags.WheeledUp });
+ tv.OnMouseEvent (new MouseEvent { Flags = MouseFlags.WheeledUp });
tv.PositionCursor ();
Assert.Equal (i - 1, tv.TopRow);
@@ -6780,7 +6780,7 @@ public void Mouse_Button_Shift_Preserves_Selection ()
Assert.Equal ("TAB to jump between text fields.", _textView.Text);
Assert.True (
- _textView.MouseEvent (
+ _textView.OnMouseEvent (
new MouseEvent { X = 12, Y = 0, Flags = MouseFlags.Button1Pressed | MouseFlags.ButtonShift }
)
);
@@ -6790,7 +6790,7 @@ public void Mouse_Button_Shift_Preserves_Selection ()
Assert.True (_textView.Selecting);
Assert.Equal ("TAB to jump ", _textView.SelectedText);
- Assert.True (_textView.MouseEvent (new MouseEvent { X = 12, Y = 0, Flags = MouseFlags.Button1Clicked }));
+ Assert.True (_textView.OnMouseEvent (new MouseEvent { X = 12, Y = 0, Flags = MouseFlags.Button1Clicked }));
Assert.Equal (0, _textView.SelectionStartRow);
Assert.Equal (0, _textView.SelectionStartRow);
Assert.Equal (new Point (12, 0), _textView.CursorPosition);
@@ -6798,7 +6798,7 @@ public void Mouse_Button_Shift_Preserves_Selection ()
Assert.Equal ("TAB to jump ", _textView.SelectedText);
Assert.True (
- _textView.MouseEvent (
+ _textView.OnMouseEvent (
new MouseEvent { X = 19, Y = 0, Flags = MouseFlags.Button1Pressed | MouseFlags.ButtonShift }
)
);
@@ -6808,7 +6808,7 @@ public void Mouse_Button_Shift_Preserves_Selection ()
Assert.True (_textView.Selecting);
Assert.Equal ("TAB to jump between", _textView.SelectedText);
- Assert.True (_textView.MouseEvent (new MouseEvent { X = 19, Y = 0, Flags = MouseFlags.Button1Clicked }));
+ Assert.True (_textView.OnMouseEvent (new MouseEvent { X = 19, Y = 0, Flags = MouseFlags.Button1Clicked }));
Assert.Equal (0, _textView.SelectionStartRow);
Assert.Equal (0, _textView.SelectionStartRow);
Assert.Equal (new Point (19, 0), _textView.CursorPosition);
@@ -6816,7 +6816,7 @@ public void Mouse_Button_Shift_Preserves_Selection ()
Assert.Equal ("TAB to jump between", _textView.SelectedText);
Assert.True (
- _textView.MouseEvent (
+ _textView.OnMouseEvent (
new MouseEvent { X = 24, Y = 0, Flags = MouseFlags.Button1Pressed | MouseFlags.ButtonShift }
)
);
@@ -6826,14 +6826,14 @@ public void Mouse_Button_Shift_Preserves_Selection ()
Assert.True (_textView.Selecting);
Assert.Equal ("TAB to jump between text", _textView.SelectedText);
- Assert.True (_textView.MouseEvent (new MouseEvent { X = 24, Y = 0, Flags = MouseFlags.Button1Clicked }));
+ Assert.True (_textView.OnMouseEvent (new MouseEvent { X = 24, Y = 0, Flags = MouseFlags.Button1Clicked }));
Assert.Equal (0, _textView.SelectionStartRow);
Assert.Equal (0, _textView.SelectionStartRow);
Assert.Equal (new Point (24, 0), _textView.CursorPosition);
Assert.True (_textView.Selecting);
Assert.Equal ("TAB to jump between text", _textView.SelectedText);
- Assert.True (_textView.MouseEvent (new MouseEvent { X = 24, Y = 0, Flags = MouseFlags.Button1Pressed }));
+ Assert.True (_textView.OnMouseEvent (new MouseEvent { X = 24, Y = 0, Flags = MouseFlags.Button1Pressed }));
Assert.Equal (0, _textView.SelectionStartRow);
Assert.Equal (0, _textView.SelectionStartRow);
Assert.Equal (new Point (24, 0), _textView.CursorPosition);
@@ -7607,12 +7607,12 @@ public void TextView_SpaceHandling ()
var ev = new MouseEvent { X = 0, Y = 0, Flags = MouseFlags.Button1DoubleClicked };
- tv.MouseEvent (ev);
+ tv.OnMouseEvent (ev);
Assert.Equal (1, tv.SelectedLength);
ev = new MouseEvent { X = 1, Y = 0, Flags = MouseFlags.Button1DoubleClicked };
- tv.MouseEvent (ev);
+ tv.OnMouseEvent (ev);
Assert.Equal (1, tv.SelectedLength);
}
@@ -7726,7 +7726,7 @@ This is the second line.
_output
);
- Assert.True (tv.MouseEvent (new MouseEvent { X = 0, Y = 3, Flags = MouseFlags.Button1Pressed }));
+ Assert.True (tv.OnMouseEvent (new MouseEvent { X = 0, Y = 3, Flags = MouseFlags.Button1Pressed }));
tv.Draw ();
Assert.Equal (new Point (0, 3), tv.CursorPosition);
Assert.Equal (new Point (13, 0), cp);
diff --git a/UnitTests/Views/ToplevelTests.cs b/UnitTests/Views/ToplevelTests.cs
index d6c3676771..cdcd2620a3 100644
--- a/UnitTests/Views/ToplevelTests.cs
+++ b/UnitTests/Views/ToplevelTests.cs
@@ -384,12 +384,12 @@ public void Internal_Tests ()
Assert.Equal (new Rectangle (0, 1, 60, 15), win.Frame);
Assert.Null (Toplevel._dragPosition);
- win.MouseEvent (new MouseEvent { X = 6, Y = 0, Flags = MouseFlags.Button1Pressed });
+ win.OnMouseEvent (new MouseEvent { X = 6, Y = 0, Flags = MouseFlags.Button1Pressed });
Assert.Equal (new Point (6, 0), Toplevel._dragPosition);
- win.MouseEvent (new MouseEvent { X = 6, Y = 0, Flags = MouseFlags.Button1Released });
+ win.OnMouseEvent (new MouseEvent { X = 6, Y = 0, Flags = MouseFlags.Button1Released });
Assert.Null (Toplevel._dragPosition);
win.CanFocus = false;
- win.MouseEvent (new MouseEvent { X = 6, Y = 0, Flags = MouseFlags.Button1Pressed });
+ win.OnMouseEvent (new MouseEvent { X = 6, Y = 0, Flags = MouseFlags.Button1Pressed });
Assert.Null (Toplevel._dragPosition);
}
diff --git a/UnitTests/Views/TreeViewTests.cs b/UnitTests/Views/TreeViewTests.cs
index d170a7ec32..5b180870b6 100644
--- a/UnitTests/Views/TreeViewTests.cs
+++ b/UnitTests/Views/TreeViewTests.cs
@@ -452,7 +452,7 @@ public void ObjectActivationButton_DoubleClick ()
Assert.False (called);
// double click triggers activation
- tree.MouseEvent (new MouseEvent { Y = 0, Flags = MouseFlags.Button1DoubleClicked });
+ tree.OnMouseEvent (new MouseEvent { Y = 0, Flags = MouseFlags.Button1DoubleClicked });
Assert.True (called);
Assert.Same (f, activated);
@@ -484,12 +484,12 @@ public void ObjectActivationButton_RightClick ()
Assert.False (called);
// double click does nothing because we changed button binding to right click
- tree.MouseEvent (new MouseEvent { Y = 1, Flags = MouseFlags.Button1DoubleClicked });
+ tree.OnMouseEvent (new MouseEvent { Y = 1, Flags = MouseFlags.Button1DoubleClicked });
Assert.Null (activated);
Assert.False (called);
- tree.MouseEvent (new MouseEvent { Y = 1, Flags = MouseFlags.Button2Clicked });
+ tree.OnMouseEvent (new MouseEvent { Y = 1, Flags = MouseFlags.Button2Clicked });
Assert.True (called);
Assert.Same (car1, activated);
@@ -521,7 +521,7 @@ public void ObjectActivationButton_SetToNull ()
Assert.False (called);
// double click does nothing because we changed button to null
- tree.MouseEvent (new MouseEvent { Y = 0, Flags = MouseFlags.Button1DoubleClicked });
+ tree.OnMouseEvent (new MouseEvent { Y = 0, Flags = MouseFlags.Button1DoubleClicked });
Assert.False (called);
Assert.Null (activated);