|
@@ -67,52 +67,62 @@ public class Button : View
|
|
|
|
|
|
private void Button_MouseEvent (object sender, MouseEventEventArgs e)
|
|
|
{
|
|
|
- if (e.MouseEvent.Flags.HasFlag(MouseFlags.Button1Clicked))
|
|
|
+ // Default behavior is to invoke Accept (via HotKey) on clicked.
|
|
|
+ if (!WantContinuousButtonPressed &&
|
|
|
+ Application.MouseGrabView != this &&
|
|
|
+ e.MouseEvent.Flags.HasFlag (MouseFlags.Button1Clicked))
|
|
|
{
|
|
|
- if (Application.MouseGrabView != this)
|
|
|
- {
|
|
|
- e.Handled = InvokeCommand (Command.HotKey) == true;
|
|
|
-
|
|
|
- return;
|
|
|
- }
|
|
|
+ e.Handled = InvokeCommand (Command.HotKey) == true;
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
- if (e.MouseEvent.Flags == MouseFlags.Button1Pressed)
|
|
|
+ if (e.MouseEvent.Flags.HasFlag (MouseFlags.Button1Pressed))
|
|
|
{
|
|
|
- if (Application.MouseGrabView == this)
|
|
|
+ // If WantContinuousButtonPressed is true, and this is not the first pressed event,
|
|
|
+ // invoke Accept (via HotKey)
|
|
|
+ if (WantContinuousButtonPressed && Application.MouseGrabView == this)
|
|
|
{
|
|
|
e.Handled = InvokeCommand (Command.HotKey) == true;
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- SetFocus();
|
|
|
- Application.GrabMouse(this);
|
|
|
+ // The first time we get pressed event, grab the mouse and invert the colors
|
|
|
+ if (Application.MouseGrabView != this)
|
|
|
+ {
|
|
|
+ Application.GrabMouse (this);
|
|
|
+ _savedColorScheme = ColorScheme;
|
|
|
+ var cs = new ColorScheme (new Attribute (ColorScheme.Normal.Background, ColorScheme.Normal.Foreground));
|
|
|
+ ColorScheme = cs;
|
|
|
|
|
|
- _savedColorScheme = ColorScheme;
|
|
|
- var cs = new ColorScheme (new Attribute (ColorScheme.Normal.Background, ColorScheme.Normal.Foreground));
|
|
|
- ColorScheme = cs;
|
|
|
+ // Set the focus, but don't invoke Accept
|
|
|
+ SetFocus ();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- if (e.MouseEvent.Flags.HasFlag(MouseFlags.Button1Released))
|
|
|
+ if (e.MouseEvent.Flags.HasFlag (MouseFlags.Button1Released))
|
|
|
{
|
|
|
- Application.UngrabMouse ();
|
|
|
-
|
|
|
- e.Handled = InvokeCommand (Command.HotKey) == true;
|
|
|
-
|
|
|
- if (_savedColorScheme is { })
|
|
|
+ // When the mouse is released, if WantContinuousButtonPressed is set, invoke Accept one last time.
|
|
|
+ if (WantContinuousButtonPressed)
|
|
|
{
|
|
|
- ColorScheme = _savedColorScheme;
|
|
|
+ e.Handled = InvokeCommand (Command.HotKey) == true;
|
|
|
}
|
|
|
|
|
|
- _savedColorScheme = null;
|
|
|
+ if (Application.MouseGrabView == this)
|
|
|
+ {
|
|
|
+ Application.UngrabMouse ();
|
|
|
+ if (_savedColorScheme is { })
|
|
|
+ {
|
|
|
+ ColorScheme = _savedColorScheme;
|
|
|
+ _savedColorScheme = null;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
- public override bool OnLeave (View view)
|
|
|
+ protected internal override bool OnMouseLeave (MouseEvent e)
|
|
|
{
|
|
|
- //Application.UngrabMouse();
|
|
|
- return base.OnLeave (view);
|
|
|
+ return base.OnMouseLeave (e);
|
|
|
}
|
|
|
|
|
|
private void Button_MouseClick (object sender, MouseEventEventArgs e)
|