Bladeren bron

Merge branch 'develop' into fix-gha-smells

Tig 1 jaar geleden
bovenliggende
commit
391f7446f0

+ 1 - 0
Terminal.Gui/Core/Application.cs

@@ -1037,6 +1037,7 @@ namespace Terminal.Gui {
 			toplevel.LayoutSubviews ();
 			toplevel.PositionToplevels ();
 			toplevel.WillPresent ();
+			EnsuresTopOnFront ();
 			if (refreshDriver) {
 				MdiTop?.OnChildLoaded (toplevel);
 				toplevel.OnLoaded ();

+ 4 - 0
Terminal.Gui/Core/View.cs

@@ -394,6 +394,10 @@ namespace Terminal.Gui {
 								}
 							}
 						}
+
+						if (SuperView is Toplevel && Application.Current?.Focused != SuperView) {
+							Application.EnsuresTopOnFront ();
+						}
 					}
 					OnCanFocusChanged ();
 					SetNeedsDisplay ();

+ 1 - 1
Terminal.Gui/Core/Window.cs

@@ -104,7 +104,7 @@ namespace Terminal.Gui {
 
 			public override void OnCanFocusChanged ()
 			{
-				if (MostFocused == null && CanFocus && Visible) {
+				if (HasFocus && MostFocused == null && CanFocus && Visible) {
 					EnsureFocus ();
 				}
 

+ 1 - 1
UICatalog/UICatalog.csproj

@@ -22,7 +22,7 @@
   <ItemGroup>
     <PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.20.1" />
     <PackageReference Include="SixLabors.ImageSharp" Version="3.1.4" />
-    <PackageReference Include="CsvHelper" Version="32.0.3" />
+    <PackageReference Include="CsvHelper" Version="33.0.1" />
     <PackageReference Include="Microsoft.DotNet.PlatformAbstractions" Version="3.1.6" />
   </ItemGroup>
   <ItemGroup>

+ 9 - 9
UnitTests/Application/ApplicationTests.cs

@@ -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);
 		}