diff --git a/Terminal.Gui/Core/Application.cs b/Terminal.Gui/Core/Application.cs
index 990c02e71..561d6a8c4 100644
--- a/Terminal.Gui/Core/Application.cs
+++ b/Terminal.Gui/Core/Application.cs
@@ -162,7 +162,7 @@ namespace Terminal.Gui {
if (alternateForwardKey != value) {
var oldKey = alternateForwardKey;
alternateForwardKey = value;
- OnAlternateForwardKeyChanged (new KeyChangedEventArgs (oldKey, value));
+ OnAlternateForwardKeyChanged (new KeyChangedEventArgs(oldKey,value));
}
}
}
@@ -186,7 +186,7 @@ namespace Terminal.Gui {
if (alternateBackwardKey != value) {
var oldKey = alternateBackwardKey;
alternateBackwardKey = value;
- OnAlternateBackwardKeyChanged (new KeyChangedEventArgs (oldKey, value));
+ OnAlternateBackwardKeyChanged (new KeyChangedEventArgs(oldKey,value));
}
}
}
@@ -210,7 +210,7 @@ namespace Terminal.Gui {
if (quitKey != value) {
var oldKey = quitKey;
quitKey = value;
- OnQuitKeyChanged (new KeyChangedEventArgs (oldKey, value));
+ OnQuitKeyChanged (new KeyChangedEventArgs(oldKey,value));
}
}
}
@@ -720,16 +720,6 @@ namespace Terminal.Gui {
///
public static View MouseGrabView => mouseGrabView;
- ///
- /// Event to be invoked when a view want grab the mouse which can be canceled.
- ///
- public static event EventHandler GrabbingMouse;
-
- ///
- /// Event to be invoked when a view want ungrab the mouse which can be canceled.
- ///
- public static event EventHandler UnGrabbingMouse;
-
///
/// Event to be invoked when a view grab the mouse.
///
@@ -749,11 +739,9 @@ namespace Terminal.Gui {
{
if (view == null)
return;
- if (!OnGrabbingMouse (view)) {
- OnGrabbedMouse (view);
- mouseGrabView = view;
- Driver.UncookMouse ();
- }
+ OnGrabbedMouse (view);
+ mouseGrabView = view;
+ Driver.UncookMouse ();
}
///
@@ -763,36 +751,16 @@ namespace Terminal.Gui {
{
if (mouseGrabView == null)
return;
- if (!OnUnGrabbingMouse (mouseGrabView)) {
- OnUnGrabbedMouse (mouseGrabView);
- mouseGrabView = null;
- Driver.CookMouse ();
- }
- }
-
- static bool OnGrabbingMouse (View view)
- {
- if (view == null)
- return false;
- var evArgs = new GrabMouseEventArgs (view);
- GrabbingMouse?.Invoke (view, evArgs);
- return evArgs.Cancel;
- }
-
- static bool OnUnGrabbingMouse (View view)
- {
- if (view == null)
- return false;
- var evArgs = new GrabMouseEventArgs (view);
- UnGrabbingMouse?.Invoke (view, evArgs);
- return evArgs.Cancel;
+ OnUnGrabbedMouse (mouseGrabView);
+ mouseGrabView = null;
+ Driver.CookMouse ();
}
static void OnGrabbedMouse (View view)
{
if (view == null)
return;
- GrabbedMouse?.Invoke (view, new ViewEventArgs (view));
+ GrabbedMouse?.Invoke (view, new ViewEventArgs(view));
}
static void OnUnGrabbedMouse (View view)
@@ -1061,7 +1029,7 @@ namespace Terminal.Gui {
Driver.Refresh ();
}
- NotifyNewRunState?.Invoke (toplevel, new RunStateEventArgs (rs));
+ NotifyNewRunState?.Invoke (toplevel, new RunStateEventArgs(rs));
return rs;
}
@@ -1529,7 +1497,7 @@ namespace Terminal.Gui {
static void OnNotifyStopRunState (Toplevel top)
{
if (ExitRunLoopAfterFirstIteration) {
- NotifyStopRunState?.Invoke (top, new ToplevelEventArgs (top));
+ NotifyStopRunState?.Invoke (top, new ToplevelEventArgs(top));
}
}
@@ -1548,7 +1516,7 @@ namespace Terminal.Gui {
t.SetRelativeLayout (full);
t.LayoutSubviews ();
t.PositionToplevels ();
- t.OnResized (new SizeChangedEventArgs (full.Size));
+ t.OnResized (new SizeChangedEventArgs(full.Size));
}
Refresh ();
}
diff --git a/Terminal.Gui/Core/EventArgs/GrabMouseEventArgs.cs b/Terminal.Gui/Core/GrabMouseEventArgs.cs
similarity index 93%
rename from Terminal.Gui/Core/EventArgs/GrabMouseEventArgs.cs
rename to Terminal.Gui/Core/GrabMouseEventArgs.cs
index 952dc5ac6..b35667574 100644
--- a/Terminal.Gui/Core/EventArgs/GrabMouseEventArgs.cs
+++ b/Terminal.Gui/Core/GrabMouseEventArgs.cs
@@ -4,7 +4,7 @@ namespace Terminal.Gui {
///
/// Args for events that relate to specific
///
- public class GrabMouseEventArgs : EventArgs{
+ public class GrabMouseEventArgs : EventArgs {
///
/// Creates a new instance of the class.
diff --git a/Terminal.Gui/Core/EventArgs/KeyChangedEventArgs.cs b/Terminal.Gui/Core/KeyChangedEventArgs.cs
similarity index 100%
rename from Terminal.Gui/Core/EventArgs/KeyChangedEventArgs.cs
rename to Terminal.Gui/Core/KeyChangedEventArgs.cs
diff --git a/Terminal.Gui/Core/EventArgs/MenuOpenedEventArgs.cs b/Terminal.Gui/Core/MenuOpenedEventArgs.cs
similarity index 100%
rename from Terminal.Gui/Core/EventArgs/MenuOpenedEventArgs.cs
rename to Terminal.Gui/Core/MenuOpenedEventArgs.cs
diff --git a/Terminal.Gui/Core/EventArgs/MouseFlagsChangedEventArgs.cs b/Terminal.Gui/Core/MouseFlagsChangedEventArgs.cs
similarity index 100%
rename from Terminal.Gui/Core/EventArgs/MouseFlagsChangedEventArgs.cs
rename to Terminal.Gui/Core/MouseFlagsChangedEventArgs.cs
diff --git a/Terminal.Gui/Core/EventArgs/PointEventArgs.cs b/Terminal.Gui/Core/PointEventArgs.cs
similarity index 100%
rename from Terminal.Gui/Core/EventArgs/PointEventArgs.cs
rename to Terminal.Gui/Core/PointEventArgs.cs
diff --git a/Terminal.Gui/Core/EventArgs/RunStateEventArgs.cs b/Terminal.Gui/Core/RunStateEventArgs.cs
similarity index 100%
rename from Terminal.Gui/Core/EventArgs/RunStateEventArgs.cs
rename to Terminal.Gui/Core/RunStateEventArgs.cs
diff --git a/Terminal.Gui/Core/EventArgs/SizeChangedEventArgs.cs b/Terminal.Gui/Core/SizeChangedEventArgs.cs
similarity index 100%
rename from Terminal.Gui/Core/EventArgs/SizeChangedEventArgs.cs
rename to Terminal.Gui/Core/SizeChangedEventArgs.cs
diff --git a/Terminal.Gui/Core/EventArgs/SuperViewChangedEventArgs.cs b/Terminal.Gui/Core/SuperViewChangedEventArgs.cs
similarity index 100%
rename from Terminal.Gui/Core/EventArgs/SuperViewChangedEventArgs.cs
rename to Terminal.Gui/Core/SuperViewChangedEventArgs.cs
diff --git a/Terminal.Gui/Core/EventArgs/TimeoutEventArgs.cs b/Terminal.Gui/Core/TimeoutEventArgs.cs
similarity index 91%
rename from Terminal.Gui/Core/EventArgs/TimeoutEventArgs.cs
rename to Terminal.Gui/Core/TimeoutEventArgs.cs
index 6a8e04c3f..002342152 100644
--- a/Terminal.Gui/Core/EventArgs/TimeoutEventArgs.cs
+++ b/Terminal.Gui/Core/TimeoutEventArgs.cs
@@ -1,5 +1,4 @@
using System;
-using Terminal.Gui;
using static Terminal.Gui.MainLoop;
namespace Terminal.Gui {
@@ -26,8 +25,8 @@ namespace Terminal.Gui {
///
public TimeoutEventArgs (Timeout timeout, long ticks)
{
- this.Timeout = timeout;
- this.Ticks = ticks;
+ Timeout = timeout;
+ Ticks = ticks;
}
}
}
diff --git a/Terminal.Gui/Core/EventArgs/ToggleEventArgs.cs b/Terminal.Gui/Core/ToggleEventArgs.cs
similarity index 100%
rename from Terminal.Gui/Core/EventArgs/ToggleEventArgs.cs
rename to Terminal.Gui/Core/ToggleEventArgs.cs
diff --git a/Terminal.Gui/Core/Toplevel.cs b/Terminal.Gui/Core/Toplevel.cs
index 7995337ba..02727aa39 100644
--- a/Terminal.Gui/Core/Toplevel.cs
+++ b/Terminal.Gui/Core/Toplevel.cs
@@ -120,7 +120,7 @@ namespace Terminal.Gui {
internal virtual void OnChildUnloaded (Toplevel top)
{
- ChildUnloaded?.Invoke (this, new ToplevelEventArgs (top));
+ ChildUnloaded?.Invoke (this, new ToplevelEventArgs(top));
}
internal virtual void OnChildLoaded (Toplevel top)
@@ -159,7 +159,7 @@ namespace Terminal.Gui {
internal virtual void OnActivate (Toplevel deactivated)
{
- Activate?.Invoke (this, new ToplevelEventArgs (deactivated));
+ Activate?.Invoke (this, new ToplevelEventArgs(deactivated));
}
///
@@ -221,9 +221,6 @@ namespace Terminal.Gui {
{
ColorScheme = Colors.TopLevel;
- Application.GrabbingMouse += Application_GrabbingMouse;
- Application.UnGrabbingMouse += Application_UnGrabbingMouse;
-
// Things this view knows how to do
AddCommand (Command.QuitToplevel, () => { QuitToplevel (); return true; });
AddCommand (Command.Suspend, () => { Driver.Suspend (); ; return true; });
@@ -259,20 +256,6 @@ namespace Terminal.Gui {
AddKeyBinding (Key.L | Key.CtrlMask, Command.Refresh);
}
- private void Application_UnGrabbingMouse (object sender, GrabMouseEventArgs e)
- {
- if (Application.MouseGrabView == this && dragPosition.HasValue) {
- e.Cancel = true;
- }
- }
-
- private void Application_GrabbingMouse (object sender, GrabMouseEventArgs e)
- {
- if (Application.MouseGrabView == this && dragPosition.HasValue) {
- e.Cancel = true;
- }
- }
-
///
/// Invoked when the is changed.
///
@@ -841,8 +824,8 @@ namespace Terminal.Gui {
}
if (mouseEvent.Flags.HasFlag (MouseFlags.Button1Released) && dragPosition.HasValue) {
- dragPosition = null;
Application.UngrabMouse ();
+ dragPosition = null;
}
//System.Diagnostics.Debug.WriteLine ($"dragPosition after: {dragPosition.HasValue}");
diff --git a/Terminal.Gui/Core/EventArgs/ToplevelEventArgs.cs b/Terminal.Gui/Core/ToplevelEventArgs.cs
similarity index 94%
rename from Terminal.Gui/Core/EventArgs/ToplevelEventArgs.cs
rename to Terminal.Gui/Core/ToplevelEventArgs.cs
index 76be6603c..f47383919 100644
--- a/Terminal.Gui/Core/EventArgs/ToplevelEventArgs.cs
+++ b/Terminal.Gui/Core/ToplevelEventArgs.cs
@@ -4,7 +4,7 @@ namespace Terminal.Gui {
///
/// Args for events that relate to a specific .
///
- public class ToplevelEventArgs : EventArgs{
+ public class ToplevelEventArgs : EventArgs {
///
/// Creates a new instance of the class.
diff --git a/Terminal.Gui/Core/EventArgs/ViewEventArgs.cs b/Terminal.Gui/Core/ViewEventArgs.cs
similarity index 100%
rename from Terminal.Gui/Core/EventArgs/ViewEventArgs.cs
rename to Terminal.Gui/Core/ViewEventArgs.cs
diff --git a/Terminal.Gui/Core/EventArgs/DrawEventArgs.cs b/Terminal.Gui/Views/DrawEventArgs.cs
similarity index 100%
rename from Terminal.Gui/Core/EventArgs/DrawEventArgs.cs
rename to Terminal.Gui/Views/DrawEventArgs.cs