mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 15:57:56 +01:00
Fixes #3545. V1 Superview most focused view not sync with the overlapped view.
This commit is contained in:
@@ -1037,6 +1037,7 @@ namespace Terminal.Gui {
|
||||
toplevel.LayoutSubviews ();
|
||||
toplevel.PositionToplevels ();
|
||||
toplevel.WillPresent ();
|
||||
EnsuresTopOnFront ();
|
||||
if (refreshDriver) {
|
||||
MdiTop?.OnChildLoaded (toplevel);
|
||||
toplevel.OnLoaded ();
|
||||
|
||||
@@ -394,6 +394,10 @@ namespace Terminal.Gui {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (SuperView is Toplevel && Application.Current?.Focused != SuperView) {
|
||||
Application.EnsuresTopOnFront ();
|
||||
}
|
||||
}
|
||||
OnCanFocusChanged ();
|
||||
SetNeedsDisplay ();
|
||||
|
||||
@@ -104,7 +104,7 @@ namespace Terminal.Gui {
|
||||
|
||||
public override void OnCanFocusChanged ()
|
||||
{
|
||||
if (MostFocused == null && CanFocus && Visible) {
|
||||
if (HasFocus && MostFocused == null && CanFocus && Visible) {
|
||||
EnsureFocus ();
|
||||
}
|
||||
|
||||
|
||||
@@ -771,28 +771,28 @@ namespace Terminal.Gui.ApplicationTests {
|
||||
Assert.True (win.HasFocus);
|
||||
Assert.True (win2.CanFocus);
|
||||
Assert.False (win2.HasFocus);
|
||||
Assert.Equal ("win2", ((Window)top.Subviews [top.Subviews.Count - 1]).Title);
|
||||
Assert.Equal ("win", ((Window)top.Subviews [^1]).Title);
|
||||
|
||||
top.ProcessKey (new KeyEvent (Key.CtrlMask | Key.Tab, new KeyModifiers ()));
|
||||
Assert.True (win.CanFocus);
|
||||
Assert.False (win.HasFocus);
|
||||
Assert.True (win2.CanFocus);
|
||||
Assert.True (win2.HasFocus);
|
||||
Assert.Equal ("win2", ((Window)top.Subviews [top.Subviews.Count - 1]).Title);
|
||||
Assert.Equal ("win2", ((Window)top.Subviews [^1]).Title);
|
||||
|
||||
top.ProcessKey (new KeyEvent (Key.CtrlMask | Key.Tab, new KeyModifiers ()));
|
||||
Assert.True (win.CanFocus);
|
||||
Assert.True (win.HasFocus);
|
||||
Assert.True (win2.CanFocus);
|
||||
Assert.False (win2.HasFocus);
|
||||
Assert.Equal ("win", ((Window)top.Subviews [top.Subviews.Count - 1]).Title);
|
||||
Assert.Equal ("win", ((Window)top.Subviews [^1]).Title);
|
||||
|
||||
win2.MouseEvent (new MouseEvent () { Flags = MouseFlags.Button1Pressed });
|
||||
Assert.True (win.CanFocus);
|
||||
Assert.False (win.HasFocus);
|
||||
Assert.True (win2.CanFocus);
|
||||
Assert.True (win2.HasFocus);
|
||||
Assert.Equal ("win2", ((Window)top.Subviews [top.Subviews.Count - 1]).Title);
|
||||
Assert.Equal ("win2", ((Window)top.Subviews [^1]).Title);
|
||||
win2.MouseEvent (new MouseEvent () { Flags = MouseFlags.Button1Released });
|
||||
Assert.Null (Toplevel.dragPosition);
|
||||
}
|
||||
@@ -816,35 +816,35 @@ namespace Terminal.Gui.ApplicationTests {
|
||||
Assert.True (win.HasFocus);
|
||||
Assert.True (win2.CanFocus);
|
||||
Assert.False (win2.HasFocus);
|
||||
Assert.Equal ("win2", ((Window)top.Subviews [top.Subviews.Count - 1]).Title);
|
||||
Assert.Equal ("win", ((Window)top.Subviews [^1]).Title);
|
||||
|
||||
win.CanFocus = false;
|
||||
Assert.False (win.CanFocus);
|
||||
Assert.False (win.HasFocus);
|
||||
Assert.True (win2.CanFocus);
|
||||
Assert.True (win2.HasFocus);
|
||||
Assert.Equal ("win2", ((Window)top.Subviews [top.Subviews.Count - 1]).Title);
|
||||
Assert.Equal ("win2", ((Window)top.Subviews [^1]).Title);
|
||||
|
||||
top.ProcessKey (new KeyEvent (Key.CtrlMask | Key.Tab, new KeyModifiers ()));
|
||||
Assert.True (win2.CanFocus);
|
||||
Assert.False (win.HasFocus);
|
||||
Assert.True (win2.CanFocus);
|
||||
Assert.True (win2.HasFocus);
|
||||
Assert.Equal ("win2", ((Window)top.Subviews [top.Subviews.Count - 1]).Title);
|
||||
Assert.Equal ("win2", ((Window)top.Subviews [^1]).Title);
|
||||
|
||||
top.ProcessKey (new KeyEvent (Key.CtrlMask | Key.Tab, new KeyModifiers ()));
|
||||
Assert.False (win.CanFocus);
|
||||
Assert.False (win.HasFocus);
|
||||
Assert.True (win2.CanFocus);
|
||||
Assert.True (win2.HasFocus);
|
||||
Assert.Equal ("win2", ((Window)top.Subviews [top.Subviews.Count - 1]).Title);
|
||||
Assert.Equal ("win2", ((Window)top.Subviews [^1]).Title);
|
||||
|
||||
win.MouseEvent (new MouseEvent () { Flags = MouseFlags.Button1Pressed });
|
||||
Assert.False (win.CanFocus);
|
||||
Assert.False (win.HasFocus);
|
||||
Assert.True (win2.CanFocus);
|
||||
Assert.True (win2.HasFocus);
|
||||
Assert.Equal ("win2", ((Window)top.Subviews [top.Subviews.Count - 1]).Title);
|
||||
Assert.Equal ("win2", ((Window)top.Subviews [^1]).Title);
|
||||
win2.MouseEvent (new MouseEvent () { Flags = MouseFlags.Button1Released });
|
||||
Assert.Null (Toplevel.dragPosition);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user