Browse Source

Better processing of the default handler, still needs to chain to old containers for redraw

Miguel de Icaza 7 years ago
parent
commit
c763c808e3
2 changed files with 10 additions and 5 deletions
  1. 9 4
      Core.cs
  2. 1 1
      Views/Dialog.cs

+ 9 - 4
Core.cs

@@ -787,6 +787,7 @@ namespace Terminal {
 	public class Application {
 	public class Application {
 		public static ConsoleDriver Driver = new CursesDriver ();
 		public static ConsoleDriver Driver = new CursesDriver ();
 		public static Toplevel Top { get; private set; }
 		public static Toplevel Top { get; private set; }
+		public static View Current { get; private set; }
 		public static Mono.Terminal.MainLoop MainLoop { get; private set; }
 		public static Mono.Terminal.MainLoop MainLoop { get; private set; }
 
 
 		static Stack<View> toplevels = new Stack<View> ();
 		static Stack<View> toplevels = new Stack<View> ();
@@ -852,6 +853,7 @@ namespace Terminal {
 			MainLoop = new Mono.Terminal.MainLoop ();
 			MainLoop = new Mono.Terminal.MainLoop ();
 			SynchronizationContext.SetSynchronizationContext (new MainLoopSyncContext (MainLoop));
 			SynchronizationContext.SetSynchronizationContext (new MainLoopSyncContext (MainLoop));
 			Top = Toplevel.Create ();
 			Top = Toplevel.Create ();
+			Current = Top;
 			focus = Top;
 			focus = Top;
 		}
 		}
 
 
@@ -879,14 +881,14 @@ namespace Terminal {
 
 
 		static void ProcessKeyEvent (KeyEvent ke)
 		static void ProcessKeyEvent (KeyEvent ke)
 		{
 		{
-			if (Top.ProcessHotKey (ke))
+			if (Current.ProcessHotKey (ke))
 				return;
 				return;
 
 
-			if (Top.ProcessKey (ke))
+			if (Current.ProcessKey (ke))
 				return;
 				return;
 			
 			
 			// Process the key normally
 			// Process the key normally
-			if (Top.ProcessColdKey (ke))
+			if (Current.ProcessColdKey (ke))
 				return;
 				return;
 		}
 		}
 
 
@@ -899,6 +901,7 @@ namespace Terminal {
 
 
 			Init ();
 			Init ();
 			toplevels.Push (toplevel);
 			toplevels.Push (toplevel);
+			Current = toplevel;
 			Driver.PrepareToRun (MainLoop, ProcessKeyEvent);
 			Driver.PrepareToRun (MainLoop, ProcessKeyEvent);
 			toplevel.LayoutSubviews ();
 			toplevel.LayoutSubviews ();
 			toplevel.FocusFirst ();
 			toplevel.FocusFirst ();
@@ -953,8 +956,10 @@ namespace Terminal {
 			toplevels.Pop ();
 			toplevels.Pop ();
 			if (toplevels.Count == 0)
 			if (toplevels.Count == 0)
 				Shutdown ();
 				Shutdown ();
-			else
+			else {
+				Current = toplevels.Peek ();
 				Refresh ();
 				Refresh ();
+			}
 		}
 		}
 
 
 		/// <summary>
 		/// <summary>

+ 1 - 1
Views/Dialog.cs

@@ -16,7 +16,7 @@ namespace Terminal {
 	public class Dialog : Window {
 	public class Dialog : Window {
 		List<Button> buttons = new List<Button> ();
 		List<Button> buttons = new List<Button> ();
 
 
-		public Dialog (string title, int width, int height, params Button [] buttons) : base (Application.MakeCenteredRect (new Size (width, height)))
+		public Dialog (string title, int width, int height, params Button [] buttons) : base (Application.MakeCenteredRect (new Size (width, height)), title)
 		{
 		{
 			foreach (var b in buttons) {
 			foreach (var b in buttons) {
 				this.buttons.Add (b);
 				this.buttons.Add (b);