|
@@ -220,6 +220,9 @@ namespace Terminal.Gui {
|
|
{
|
|
{
|
|
ColorScheme = Colors.TopLevel;
|
|
ColorScheme = Colors.TopLevel;
|
|
|
|
|
|
|
|
+ Application.GrabbingMouse += Application_GrabbingMouse;
|
|
|
|
+ Application.UnGrabbingMouse += Application_UnGrabbingMouse;
|
|
|
|
+
|
|
// Things this view knows how to do
|
|
// Things this view knows how to do
|
|
AddCommand (Command.QuitToplevel, () => { QuitToplevel (); return true; });
|
|
AddCommand (Command.QuitToplevel, () => { QuitToplevel (); return true; });
|
|
AddCommand (Command.Suspend, () => { Driver.Suspend (); ; return true; });
|
|
AddCommand (Command.Suspend, () => { Driver.Suspend (); ; return true; });
|
|
@@ -255,6 +258,24 @@ namespace Terminal.Gui {
|
|
AddKeyBinding (Key.L | Key.CtrlMask, Command.Refresh);
|
|
AddKeyBinding (Key.L | Key.CtrlMask, Command.Refresh);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private bool Application_UnGrabbingMouse (View e)
|
|
|
|
+ {
|
|
|
|
+ if (dragPosition.HasValue) {
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private bool Application_GrabbingMouse (View e)
|
|
|
|
+ {
|
|
|
|
+ if (Application.MouseGrabView == this && dragPosition.HasValue) {
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
/// <summary>
|
|
/// <summary>
|
|
/// Invoked when the <see cref="Application.AlternateForwardKey"/> is changed.
|
|
/// Invoked when the <see cref="Application.AlternateForwardKey"/> is changed.
|
|
/// </summary>
|
|
/// </summary>
|
|
@@ -628,7 +649,8 @@ namespace Terminal.Gui {
|
|
}
|
|
}
|
|
mb = null; sb = null;
|
|
mb = null; sb = null;
|
|
if (!(superView is Toplevel)) {
|
|
if (!(superView is Toplevel)) {
|
|
- nx = x; ny = y;
|
|
|
|
|
|
+ nx = Math.Max (Math.Min (x, top.Frame.Right - 1), 0);
|
|
|
|
+ ny = Math.Max (Math.Min (y, top.Frame.Bottom - 1), 0);
|
|
return superView;
|
|
return superView;
|
|
}
|
|
}
|
|
var superViewBorder = superView.Border != null ? (superView.Border.DrawMarginFrame ? 1 : 0) : 0;
|
|
var superViewBorder = superView.Border != null ? (superView.Border.DrawMarginFrame ? 1 : 0) : 0;
|
|
@@ -835,11 +857,10 @@ namespace Terminal.Gui {
|
|
// Only start grabbing if the user clicks on the title bar.
|
|
// Only start grabbing if the user clicks on the title bar.
|
|
if (mouseEvent.Y == 0 && mouseEvent.Flags == MouseFlags.Button1Pressed) {
|
|
if (mouseEvent.Y == 0 && mouseEvent.Flags == MouseFlags.Button1Pressed) {
|
|
start = new Point (mouseEvent.X, mouseEvent.Y);
|
|
start = new Point (mouseEvent.X, mouseEvent.Y);
|
|
- dragPosition = new Point ();
|
|
|
|
|
|
+ Application.GrabMouse (this);
|
|
nx = mouseEvent.X - mouseEvent.OfX;
|
|
nx = mouseEvent.X - mouseEvent.OfX;
|
|
ny = mouseEvent.Y - mouseEvent.OfY;
|
|
ny = mouseEvent.Y - mouseEvent.OfY;
|
|
dragPosition = new Point (nx, ny);
|
|
dragPosition = new Point (nx, ny);
|
|
- Application.GrabMouse (this);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
//System.Diagnostics.Debug.WriteLine ($"Starting at {dragPosition}");
|
|
//System.Diagnostics.Debug.WriteLine ($"Starting at {dragPosition}");
|
|
@@ -872,8 +893,8 @@ namespace Terminal.Gui {
|
|
}
|
|
}
|
|
|
|
|
|
if (mouseEvent.Flags.HasFlag (MouseFlags.Button1Released) && dragPosition.HasValue) {
|
|
if (mouseEvent.Flags.HasFlag (MouseFlags.Button1Released) && dragPosition.HasValue) {
|
|
- Application.UngrabMouse ();
|
|
|
|
dragPosition = null;
|
|
dragPosition = null;
|
|
|
|
+ Application.UngrabMouse ();
|
|
}
|
|
}
|
|
|
|
|
|
//System.Diagnostics.Debug.WriteLine ($"dragPosition after: {dragPosition.HasValue}");
|
|
//System.Diagnostics.Debug.WriteLine ($"dragPosition after: {dragPosition.HasValue}");
|
|
@@ -1032,6 +1053,16 @@ namespace Terminal.Gui {
|
|
{
|
|
{
|
|
return MostFocused?.OnLeave (view) ?? base.OnLeave (view);
|
|
return MostFocused?.OnLeave (view) ?? base.OnLeave (view);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ ///<inheritdoc/>
|
|
|
|
+ protected override void Dispose (bool disposing)
|
|
|
|
+ {
|
|
|
|
+ Application.GrabbingMouse -= Application_GrabbingMouse;
|
|
|
|
+ Application.UnGrabbingMouse -= Application_UnGrabbingMouse;
|
|
|
|
+
|
|
|
|
+ dragPosition = null;
|
|
|
|
+ base.Dispose (disposing);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|