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

This commit is contained in:
Miguel de Icaza
2018-01-06 23:12:37 -05:00
parent 7447a81e52
commit c763c808e3
2 changed files with 10 additions and 5 deletions

13
Core.cs
View File

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

View File

@@ -16,7 +16,7 @@ namespace Terminal {
public class Dialog : Window {
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) {
this.buttons.Add (b);