瀏覽代碼

View.Mouse cleanup - WIP2

Tig 9 月之前
父節點
當前提交
a19781c53b

+ 1 - 1
Terminal.Gui/Text/Autocomplete/PopupAutocomplete.PopUp.cs

@@ -25,6 +25,6 @@ public abstract partial class PopupAutocomplete
             _autoComplete.RenderOverlay (_autoComplete.LastPopupPos.Value);
             _autoComplete.RenderOverlay (_autoComplete.LastPopupPos.Value);
         }
         }
 
 
-        protected internal override bool OnMouseEvent (MouseEvent mouseEvent) { return _autoComplete.OnMouseEvent (mouseEvent); }
+        protected override bool OnMouseEvent (MouseEvent mouseEvent) { return _autoComplete.OnMouseEvent (mouseEvent); }
     }
     }
 }
 }

+ 2 - 2
Terminal.Gui/View/Adornment/Border.cs

@@ -262,9 +262,9 @@ public class Border : Adornment
     private Point _startGrabPoint;
     private Point _startGrabPoint;
 
 
     /// <inheritdoc/>
     /// <inheritdoc/>
-    protected internal override bool OnMouseEvent (MouseEvent mouseEvent)
+    protected override bool OnMouseEvent (MouseEvent mouseEvent)
     {
     {
-        if (base.OnMouseEvent (mouseEvent))
+        if (base.RaiseMouseEvent (mouseEvent))
         {
         {
             return true;
             return true;
         }
         }

+ 1 - 1
Terminal.Gui/View/Adornment/Padding.cs

@@ -50,7 +50,7 @@ public class Padding : Adornment
     /// </remarks>
     /// </remarks>
     /// <param name="mouseEvent"></param>
     /// <param name="mouseEvent"></param>
     /// <returns><see langword="true"/>, if the event was handled, <see langword="false"/> otherwise.</returns>
     /// <returns><see langword="true"/>, if the event was handled, <see langword="false"/> otherwise.</returns>
-    protected internal override bool OnMouseEvent (MouseEvent mouseEvent)
+    protected override bool OnMouseEvent (MouseEvent mouseEvent)
     {
     {
         if (Parent is null)
         if (Parent is null)
         {
         {

+ 23 - 8
Terminal.Gui/View/View.Mouse.cs

@@ -212,14 +212,14 @@ public partial class View // Mouse APIs
     ///         A view must be both enabled and visible to receive mouse events.
     ///         A view must be both enabled and visible to receive mouse events.
     ///     </para>
     ///     </para>
     ///     <para>
     ///     <para>
-    ///         This method raises <see cref="OnMouseEvent"/>/<see cref="MouseEvent"/>; if not handled, and one of the
+    ///         This method raises <see cref="RaiseMouseEvent"/>/<see cref="MouseEvent"/>; if not handled, and one of the
     ///         mouse buttons was clicked, the <see cref="OnMouseClick"/>/<see cref="MouseClick"/> event will be raised
     ///         mouse buttons was clicked, the <see cref="OnMouseClick"/>/<see cref="MouseClick"/> event will be raised
     ///     </para>
     ///     </para>
     ///     <para>
     ///     <para>
     ///         See <see cref="SetPressedHighlight"/> for more information.
     ///         See <see cref="SetPressedHighlight"/> for more information.
     ///     </para>
     ///     </para>
     ///     <para>
     ///     <para>
-    ///         If <see cref="WantContinuousButtonPressed"/> is <see langword="true"/>, the <see cref="OnMouseEvent"/>/<see cref="MouseEvent"/> event
+    ///         If <see cref="WantContinuousButtonPressed"/> is <see langword="true"/>, the <see cref="RaiseMouseEvent"/>/<see cref="MouseEvent"/> event
     ///         will be raised on any new mouse event where <see cref="MouseEvent.Flags"/> indicates a button is pressed.
     ///         will be raised on any new mouse event where <see cref="MouseEvent.Flags"/> indicates a button is pressed.
     ///     </para>
     ///     </para>
     /// </remarks>
     /// </remarks>
@@ -245,7 +245,7 @@ public partial class View // Mouse APIs
         }
         }
 
 
         // Cancellable event
         // Cancellable event
-        if (OnMouseEvent (mouseEvent))
+        if (RaiseMouseEvent (mouseEvent))
         {
         {
             // Technically mouseEvent.Handled should already be true if implementers of OnMouseEvent
             // Technically mouseEvent.Handled should already be true if implementers of OnMouseEvent
             // follow the rules. But we'll update it just in case.
             // follow the rules. But we'll update it just in case.
@@ -296,6 +296,25 @@ public partial class View // Mouse APIs
         return false;
         return false;
     }
     }
 
 
+    /// <summary>
+    ///     Raises the <see cref="RaiseMouseEvent"/>/<see cref="MouseEvent"/> event.
+    /// </summary>
+    /// <param name="mouseEvent"></param>
+    /// <returns><see langword="true"/>, if the event was handled, <see langword="false"/> otherwise.</returns>
+    public bool RaiseMouseEvent (MouseEvent mouseEvent)
+    {
+        var args = new MouseEventEventArgs (mouseEvent);
+
+        if (OnMouseEvent (mouseEvent) || mouseEvent.Handled == true)
+        {
+            return true;
+        }
+
+        MouseEvent?.Invoke (this, args);
+
+        return args.Handled;
+    }
+
     /// <summary>Called when a mouse event occurs within the view's <see cref="Viewport"/>.</summary>
     /// <summary>Called when a mouse event occurs within the view's <see cref="Viewport"/>.</summary>
     /// <remarks>
     /// <remarks>
     ///     <para>
     ///     <para>
@@ -306,11 +325,7 @@ public partial class View // Mouse APIs
     /// <returns><see langword="true"/>, if the event was handled, <see langword="false"/> otherwise.</returns>
     /// <returns><see langword="true"/>, if the event was handled, <see langword="false"/> otherwise.</returns>
     protected virtual bool OnMouseEvent (MouseEvent mouseEvent)
     protected virtual bool OnMouseEvent (MouseEvent mouseEvent)
     {
     {
-        var args = new MouseEventEventArgs (mouseEvent);
-
-        MouseEvent?.Invoke (this, args);
-
-        return args.Handled;
+        return false;
     }
     }
 
 
     /// <summary>Raised when a mouse event occurs.</summary>
     /// <summary>Raised when a mouse event occurs.</summary>

+ 2 - 3
Terminal.Gui/Views/ColorBar.cs

@@ -110,7 +110,7 @@ internal abstract class ColorBar : View, IColorBar
     public event EventHandler<EventArgs<int>>? ValueChanged;
     public event EventHandler<EventArgs<int>>? ValueChanged;
 
 
     /// <inheritdoc/>
     /// <inheritdoc/>
-    protected internal override bool OnMouseEvent (MouseEvent mouseEvent)
+    protected override bool OnMouseEvent (MouseEvent mouseEvent)
     {
     {
         if (mouseEvent.Flags.HasFlag (MouseFlags.Button1Pressed))
         if (mouseEvent.Flags.HasFlag (MouseFlags.Button1Pressed))
         {
         {
@@ -123,10 +123,9 @@ internal abstract class ColorBar : View, IColorBar
             mouseEvent.Handled = true;
             mouseEvent.Handled = true;
             SetFocus ();
             SetFocus ();
 
 
-            return true;
         }
         }
 
 
-        return base.OnMouseEvent (mouseEvent);
+        return mouseEvent.Handled;
     }
     }
 
 
     /// <summary>
     /// <summary>

+ 2 - 2
Terminal.Gui/Views/ComboBox.cs

@@ -253,7 +253,7 @@ public class ComboBox : View, IDesignable
     public event EventHandler Expanded;
     public event EventHandler Expanded;
 
 
     /// <inheritdoc/>
     /// <inheritdoc/>
-    protected internal override bool OnMouseEvent (MouseEvent me)
+    protected override bool OnMouseEvent (MouseEvent me)
     {
     {
         if (me.Position.X == Viewport.Right - 1
         if (me.Position.X == Viewport.Right - 1
             && me.Position.Y == Viewport.Top
             && me.Position.Y == Viewport.Top
@@ -837,7 +837,7 @@ public class ComboBox : View, IDesignable
         }
         }
 
 
         // BUGBUG: OnMouseEvent is internal!
         // BUGBUG: OnMouseEvent is internal!
-        protected internal override bool OnMouseEvent (MouseEvent me)
+        protected override bool OnMouseEvent (MouseEvent me)
         {
         {
             var res = false;
             var res = false;
             bool isMousePositionValid = IsMousePositionValid (me);
             bool isMousePositionValid = IsMousePositionValid (me);

+ 1 - 1
Terminal.Gui/Views/DateField.cs

@@ -114,7 +114,7 @@ public class DateField : TextField
     }
     }
 
 
     /// <inheritdoc/>
     /// <inheritdoc/>
-    protected internal override bool OnMouseEvent  (MouseEvent ev)
+    protected override bool OnMouseEvent  (MouseEvent ev)
     {
     {
         bool result = base.OnMouseEvent (ev);
         bool result = base.OnMouseEvent (ev);
 
 

+ 1 - 1
Terminal.Gui/Views/HexView.cs

@@ -250,7 +250,7 @@ public class HexView : View, IDesignable
     public event EventHandler<HexViewEditEventArgs> Edited;
     public event EventHandler<HexViewEditEventArgs> Edited;
 
 
     /// <inheritdoc/>
     /// <inheritdoc/>
-    protected internal override bool OnMouseEvent (MouseEvent me)
+    protected override bool OnMouseEvent (MouseEvent me)
     {
     {
         if (!me.Flags.HasFlag (MouseFlags.Button1Clicked)
         if (!me.Flags.HasFlag (MouseFlags.Button1Clicked)
             && !me.Flags.HasFlag (MouseFlags.Button1DoubleClicked)
             && !me.Flags.HasFlag (MouseFlags.Button1DoubleClicked)

+ 1 - 1
Terminal.Gui/Views/ListView.cs

@@ -472,7 +472,7 @@ public class ListView : View, IDesignable
     }
     }
 
 
     /// <inheritdoc/>
     /// <inheritdoc/>
-    protected internal override bool OnMouseEvent (MouseEvent me)
+    protected override bool OnMouseEvent (MouseEvent me)
     {
     {
         if (!me.Flags.HasFlag (MouseFlags.Button1Clicked)
         if (!me.Flags.HasFlag (MouseFlags.Button1Clicked)
             && !me.Flags.HasFlag (MouseFlags.Button1DoubleClicked)
             && !me.Flags.HasFlag (MouseFlags.Button1DoubleClicked)

+ 1 - 1
Terminal.Gui/Views/Menu/Menu.cs

@@ -806,7 +806,7 @@ internal sealed class Menu : View
         _host.SetNeedsDisplay ();
         _host.SetNeedsDisplay ();
     }
     }
 
 
-    protected internal override bool OnMouseEvent (MouseEvent me)
+    protected override bool OnMouseEvent (MouseEvent me)
     {
     {
         if (!_host._handled && !_host.HandleGrabView (me, this))
         if (!_host._handled && !_host.HandleGrabView (me, this))
         {
         {

+ 1 - 1
Terminal.Gui/Views/Menu/MenuBar.cs

@@ -1400,7 +1400,7 @@ public class MenuBar : View, IDesignable
     }
     }
 
 
     /// <inheritdoc/>
     /// <inheritdoc/>
-    protected internal override bool OnMouseEvent (MouseEvent me)
+    protected bool OnMouseEvent (MouseEvent me)
     {
     {
         if (!_handled && !HandleGrabView (me, this))
         if (!_handled && !HandleGrabView (me, this))
         {
         {

+ 1 - 1
Terminal.Gui/Views/ScrollBarView.cs

@@ -270,7 +270,7 @@ public class ScrollBarView : View
     public event EventHandler ChangedPosition;
     public event EventHandler ChangedPosition;
 
 
     /// <inheritdoc/>
     /// <inheritdoc/>
-    protected internal override bool OnMouseEvent (MouseEvent mouseEvent)
+    protected override bool OnMouseEvent (MouseEvent mouseEvent)
     {
     {
         if (mouseEvent.Flags != MouseFlags.Button1Pressed
         if (mouseEvent.Flags != MouseFlags.Button1Pressed
             && mouseEvent.Flags != MouseFlags.Button1DoubleClicked
             && mouseEvent.Flags != MouseFlags.Button1DoubleClicked

+ 6 - 6
Terminal.Gui/Views/ScrollView.cs

@@ -406,7 +406,7 @@ public class ScrollView : View
     }
     }
 
 
     /// <inheritdoc/>
     /// <inheritdoc/>
-    protected internal override bool OnMouseEvent (MouseEvent me)
+    protected override bool OnMouseEvent (MouseEvent me)
     {
     {
         if (!Enabled)
         if (!Enabled)
         {
         {
@@ -416,19 +416,19 @@ public class ScrollView : View
 
 
         if (me.Flags == MouseFlags.WheeledDown && ShowVerticalScrollIndicator)
         if (me.Flags == MouseFlags.WheeledDown && ShowVerticalScrollIndicator)
         {
         {
-            ScrollDown (1);
+            return ScrollDown (1);
         }
         }
         else if (me.Flags == MouseFlags.WheeledUp && ShowVerticalScrollIndicator)
         else if (me.Flags == MouseFlags.WheeledUp && ShowVerticalScrollIndicator)
         {
         {
-            ScrollUp (1);
+            return ScrollUp (1);
         }
         }
         else if (me.Flags == MouseFlags.WheeledRight && _showHorizontalScrollIndicator)
         else if (me.Flags == MouseFlags.WheeledRight && _showHorizontalScrollIndicator)
         {
         {
-            ScrollRight (1);
+            return ScrollRight (1);
         }
         }
         else if (me.Flags == MouseFlags.WheeledLeft && ShowVerticalScrollIndicator)
         else if (me.Flags == MouseFlags.WheeledLeft && ShowVerticalScrollIndicator)
         {
         {
-            ScrollLeft (1);
+            return ScrollLeft (1);
         }
         }
         else if (me.Position.X == _vertical.Frame.X && ShowVerticalScrollIndicator)
         else if (me.Position.X == _vertical.Frame.X && ShowVerticalScrollIndicator)
         {
         {
@@ -443,7 +443,7 @@ public class ScrollView : View
             Application.UngrabMouse ();
             Application.UngrabMouse ();
         }
         }
 
 
-        return base.OnMouseEvent (me);
+        return me.Handled;
     }
     }
 
 
     /// <inheritdoc/>
     /// <inheritdoc/>

+ 1 - 1
Terminal.Gui/Views/Slider.cs

@@ -1282,7 +1282,7 @@ public class Slider<T> : View, IOrientation
     private Point? _moveRenderPosition;
     private Point? _moveRenderPosition;
 
 
     /// <inheritdoc/>
     /// <inheritdoc/>
-    protected internal override bool OnMouseEvent (MouseEvent mouseEvent)
+    protected override bool OnMouseEvent (MouseEvent mouseEvent)
     {
     {
         // Note(jmperricone): Maybe we click to focus the cursor, and on next click we set the option.
         // Note(jmperricone): Maybe we click to focus the cursor, and on next click we set the option.
         //                    That will make OptionFocused Event more relevant.
         //                    That will make OptionFocused Event more relevant.

+ 1 - 1
Terminal.Gui/Views/TabView.cs

@@ -569,7 +569,7 @@ public class TabView : View
             Add (_rightScrollIndicator, _leftScrollIndicator);
             Add (_rightScrollIndicator, _leftScrollIndicator);
         }
         }
 
 
-        protected internal override bool OnMouseEvent (MouseEvent me)
+        protected override bool OnMouseEvent (MouseEvent me)
         {
         {
             Tab hit = me.View is Tab ? (Tab)me.View : null;
             Tab hit = me.View is Tab ? (Tab)me.View : null;
 
 

+ 4 - 3
Terminal.Gui/Views/TableView/TableView.cs

@@ -801,7 +801,7 @@ public class TableView : View
     }
     }
 
 
     ///<inheritdoc/>
     ///<inheritdoc/>
-    protected internal override bool OnMouseEvent (MouseEvent me)
+    protected override bool OnMouseEvent (MouseEvent me)
     {
     {
         if (!me.Flags.HasFlag (MouseFlags.Button1Clicked)
         if (!me.Flags.HasFlag (MouseFlags.Button1Clicked)
             && !me.Flags.HasFlag (MouseFlags.Button1DoubleClicked)
             && !me.Flags.HasFlag (MouseFlags.Button1DoubleClicked)
@@ -892,6 +892,7 @@ public class TableView : View
                 }
                 }
 
 
                 Update ();
                 Update ();
+                me.Handled = true;
             }
             }
         }
         }
 
 
@@ -902,11 +903,11 @@ public class TableView : View
 
 
             if (hit is { })
             if (hit is { })
             {
             {
-                OnCellActivated (new CellActivatedEventArgs (Table, hit.Value.X, hit.Value.Y));
+                return OnCellActivated (new CellActivatedEventArgs (Table, hit.Value.X, hit.Value.Y));
             }
             }
         }
         }
 
 
-        return base.OnMouseEvent (me);
+        return me.Handled;
     }
     }
 
 
     ///<inheritdoc/>
     ///<inheritdoc/>

+ 2 - 2
Terminal.Gui/Views/TextField.cs

@@ -798,7 +798,7 @@ public class TextField : View
     }
     }
 
 
     /// <inheritdoc/>
     /// <inheritdoc/>
-    protected internal override bool OnMouseEvent (MouseEvent ev)
+    protected override bool OnMouseEvent (MouseEvent ev)
     {
     {
         if (!ev.Flags.HasFlag (MouseFlags.Button1Pressed)
         if (!ev.Flags.HasFlag (MouseFlags.Button1Pressed)
             && !ev.Flags.HasFlag (MouseFlags.ReportMousePosition)
             && !ev.Flags.HasFlag (MouseFlags.ReportMousePosition)
@@ -807,7 +807,7 @@ public class TextField : View
             && !ev.Flags.HasFlag (MouseFlags.Button1TripleClicked)
             && !ev.Flags.HasFlag (MouseFlags.Button1TripleClicked)
             && !ev.Flags.HasFlag (ContextMenu.MouseFlags))
             && !ev.Flags.HasFlag (ContextMenu.MouseFlags))
         {
         {
-            return base.OnMouseEvent (ev);
+            return false;
         }
         }
 
 
         if (!CanFocus)
         if (!CanFocus)

+ 1 - 1
Terminal.Gui/Views/TextValidateField.cs

@@ -531,7 +531,7 @@ namespace Terminal.Gui
         }
         }
 
 
         /// <inheritdoc/>
         /// <inheritdoc/>
-        protected internal override bool OnMouseEvent (MouseEvent mouseEvent)
+        protected override bool OnMouseEvent (MouseEvent mouseEvent)
         {
         {
             if (mouseEvent.Flags.HasFlag (MouseFlags.Button1Pressed))
             if (mouseEvent.Flags.HasFlag (MouseFlags.Button1Pressed))
             {
             {

+ 2 - 2
Terminal.Gui/Views/TextView.cs

@@ -3274,7 +3274,7 @@ public class TextView : View
     }
     }
 
 
     /// <inheritdoc/>
     /// <inheritdoc/>
-    protected internal override bool OnMouseEvent (MouseEvent ev)
+    protected override bool OnMouseEvent (MouseEvent ev)
     {
     {
         if (!ev.Flags.HasFlag (MouseFlags.Button1Clicked)
         if (!ev.Flags.HasFlag (MouseFlags.Button1Clicked)
             && !ev.Flags.HasFlag (MouseFlags.Button1Pressed)
             && !ev.Flags.HasFlag (MouseFlags.Button1Pressed)
@@ -3288,7 +3288,7 @@ public class TextView : View
             && !ev.Flags.HasFlag (MouseFlags.Button1TripleClicked)
             && !ev.Flags.HasFlag (MouseFlags.Button1TripleClicked)
             && !ev.Flags.HasFlag (ContextMenu!.MouseFlags))
             && !ev.Flags.HasFlag (ContextMenu!.MouseFlags))
         {
         {
-            return base.OnMouseEvent (ev);
+            return false;
         }
         }
 
 
         if (!CanFocus)
         if (!CanFocus)

+ 1 - 1
Terminal.Gui/Views/TileView.cs

@@ -910,7 +910,7 @@ public class TileView : View
             }
             }
         }
         }
 
 
-        protected internal override bool OnMouseEvent (MouseEvent mouseEvent)
+        protected override bool OnMouseEvent (MouseEvent mouseEvent)
         {
         {
             if (!dragPosition.HasValue && mouseEvent.Flags == MouseFlags.Button1Pressed)
             if (!dragPosition.HasValue && mouseEvent.Flags == MouseFlags.Button1Pressed)
             {
             {

+ 1 - 1
Terminal.Gui/Views/TimeField.cs

@@ -163,7 +163,7 @@ public class TimeField : TextField
     }
     }
 
 
     /// <inheritdoc/>
     /// <inheritdoc/>
-    protected internal override bool OnMouseEvent  (MouseEvent ev)
+    protected override bool OnMouseEvent  (MouseEvent ev)
     {
     {
         bool result = base.OnMouseEvent (ev);
         bool result = base.OnMouseEvent (ev);
 
 

+ 2 - 2
Terminal.Gui/Views/TreeView/TreeView.cs

@@ -990,7 +990,7 @@ public class TreeView<T> : View, ITreeView where T : class
 
 
     // BUGBUG: OnMouseEvent is internal. TreeView should not be overriding.
     // BUGBUG: OnMouseEvent is internal. TreeView should not be overriding.
     ///<inheritdoc/>
     ///<inheritdoc/>
-    protected internal override bool OnMouseEvent (MouseEvent me)
+    protected override bool OnMouseEvent (MouseEvent me)
     {
     {
         // If it is not an event we care about
         // If it is not an event we care about
         if (!me.Flags.HasFlag (MouseFlags.Button1Clicked)
         if (!me.Flags.HasFlag (MouseFlags.Button1Clicked)
@@ -1001,7 +1001,7 @@ public class TreeView<T> : View, ITreeView where T : class
             && !me.Flags.HasFlag (MouseFlags.WheeledLeft))
             && !me.Flags.HasFlag (MouseFlags.WheeledLeft))
         {
         {
             // do nothing
             // do nothing
-            return base.OnMouseEvent (me);
+            return false;
         }
         }
 
 
         if (!HasFocus && CanFocus)
         if (!HasFocus && CanFocus)

+ 6 - 2
UICatalog/Scenarios/LineDrawing.cs

@@ -96,6 +96,8 @@ internal class DrawLineTool : ITool
                 area.SetNeedsDisplay ();
                 area.SetNeedsDisplay ();
             }
             }
         }
         }
+
+        mouseEvent.Handled = true;
     }
     }
 }
 }
 
 
@@ -325,7 +327,7 @@ public class DrawingArea : View
     {
     {
         CurrentTool.OnMouseEvent (this, mouseEvent);
         CurrentTool.OnMouseEvent (this, mouseEvent);
 
 
-        return base.OnMouseEvent (mouseEvent);
+        return mouseEvent.Handled;
     }
     }
 
 
     internal void AddLayer ()
     internal void AddLayer ()
@@ -441,9 +443,11 @@ public class AttributeView : View
             {
             {
                 ClickedInBackground ();
                 ClickedInBackground ();
             }
             }
+
+            mouseEvent.Handled = true;
         }
         }
 
 
-        return base.OnMouseEvent (mouseEvent);
+        return mouseEvent.Handled;
     }
     }
 
 
     private bool IsForegroundPoint (int x, int y) { return ForegroundPoints.Contains ((x, y)); }
     private bool IsForegroundPoint (int x, int y) { return ForegroundPoints.Contains ((x, y)); }

+ 4 - 4
UnitTests/Views/ColorPickerTests.cs

@@ -120,7 +120,7 @@ public class ColorPickerTests
 
 
         Assert.IsAssignableFrom<IColorBar> (cp.Focused);
         Assert.IsAssignableFrom<IColorBar> (cp.Focused);
 
 
-        cp.Focused.OnMouseEvent (
+        cp.Focused.RaiseMouseEvent (
                                  new ()
                                  new ()
                                  {
                                  {
                                      Flags = MouseFlags.Button1Pressed,
                                      Flags = MouseFlags.Button1Pressed,
@@ -132,7 +132,7 @@ public class ColorPickerTests
         Assert.Equal (3, r.TrianglePosition);
         Assert.Equal (3, r.TrianglePosition);
         Assert.Equal ("#0F0000", hex.Text);
         Assert.Equal ("#0F0000", hex.Text);
 
 
-        cp.Focused.OnMouseEvent (
+        cp.Focused.RaiseMouseEvent (
                                   new ()
                                   new ()
                                   {
                                   {
                                       Flags = MouseFlags.Button1Pressed,
                                       Flags = MouseFlags.Button1Pressed,
@@ -269,7 +269,7 @@ public class ColorPickerTests
         cp.Draw ();
         cp.Draw ();
 
 
         // Click at the end of the Red bar
         // Click at the end of the Red bar
-        cp.Focused.OnMouseEvent (
+        cp.Focused.RaiseMouseEvent (
                                  new ()
                                  new ()
                                  {
                                  {
                                      Flags = MouseFlags.Button1Pressed,
                                      Flags = MouseFlags.Button1Pressed,
@@ -303,7 +303,7 @@ public class ColorPickerTests
         cp.Draw ();
         cp.Draw ();
 
 
         // Click beyond the bar
         // Click beyond the bar
-        cp.Focused.OnMouseEvent (
+        cp.Focused.RaiseMouseEvent (
                                  new ()
                                  new ()
                                  {
                                  {
                                      Flags = MouseFlags.Button1Pressed,
                                      Flags = MouseFlags.Button1Pressed,