diff --git a/src/Eto.Mac/Forms/Controls/NativeControlHandler.cs b/src/Eto.Mac/Forms/Controls/NativeControlHandler.cs index 49d0d2a9e..11ec2ed74 100644 --- a/src/Eto.Mac/Forms/Controls/NativeControlHandler.cs +++ b/src/Eto.Mac/Forms/Controls/NativeControlHandler.cs @@ -52,7 +52,7 @@ NSView CreateHost(object nativeControl) { if (nativeControl == null) { - return new NSView(); + return new MacPanelView(); } else if (nativeControl is NSView view) { diff --git a/src/Eto.Mac/Forms/Controls/SplitterHandler.cs b/src/Eto.Mac/Forms/Controls/SplitterHandler.cs index 05ab467d1..ff3d5d036 100644 --- a/src/Eto.Mac/Forms/Controls/SplitterHandler.cs +++ b/src/Eto.Mac/Forms/Controls/SplitterHandler.cs @@ -225,6 +225,11 @@ void ResizeSubviews(CGSize oldSize2) } } + if (newFrame.Width <= 0) + panel1Rect.Width = panel1Rect.X = panel2Rect.Width = panel2Rect.X = 0; + if (newFrame.Height <= 0) + panel1Rect.Height = panel1Rect.Y = panel2Rect.Height = panel2Rect.Y = 0; + splitView.Subviews[0].Frame = panel1Rect; splitView.Subviews[1].Frame = panel2Rect; //Console.WriteLine($"Splitter resize: frame: {splitView.Frame.Size}, position: {position}, panel1({panel1?.Visible}): {panel1Rect}, panel2({panel2?.Visible}): {panel2Rect}"); diff --git a/src/Eto/Forms/Application.cs b/src/Eto/Forms/Application.cs index 4da10784a..272591321 100644 --- a/src/Eto/Forms/Application.cs +++ b/src/Eto/Forms/Application.cs @@ -22,9 +22,7 @@ public enum UIThreadCheckMode /// /// Exception thrown when a control method is accessed in a non-UI thread using . /// -#if NETSTANDARD2_0_OR_GREATER [System.Serializable] -#endif public class UIThreadAccessException : System.Exception { /// @@ -42,7 +40,6 @@ public UIThreadAccessException(string message) : base(message) { } /// Message for the exception /// Inner exception public UIThreadAccessException(string message, System.Exception inner) : base(message, inner) { } -#if NETSTANDARD2_0_OR_GREATER /// /// Initializes a new instance of the UIThreadAccessException class from serialization /// @@ -51,7 +48,6 @@ public UIThreadAccessException(string message, System.Exception inner) : base(me protected UIThreadAccessException( System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) : base(info, context) { } -#endif } /// @@ -65,9 +61,7 @@ protected UIThreadAccessException( [Handler(typeof(Application.IHandler))] public class Application : Widget { -#if NETSTANDARD2_0_OR_GREATER Thread mainThread; -#endif LocalizeEventArgs localizeArgs; readonly object localizeLock = new object(); static readonly object ApplicationKey = new object(); @@ -313,9 +307,7 @@ public Application(Platform platform) : this(InitializePlatform(platform)) { Instance = this; -#if NETSTANDARD2_0_OR_GREATER mainThread = System.Threading.Thread.CurrentThread; -#endif } Application(InitHelper init) @@ -350,7 +342,6 @@ static InitHelper InitializePlatform(Platform platform) /// public void EnsureUIThread() { -#if NETSTANDARD2_0_OR_GREATER if (UIThreadCheckMode == UIThreadCheckMode.None) return; if (mainThread == Thread.CurrentThread) @@ -359,7 +350,6 @@ public void EnsureUIThread() System.Diagnostics.Trace.WriteLine("Warning: Accessing UI object from a non-UI thread. UI objects can only be used from the main thread."); else if (UIThreadCheckMode == UIThreadCheckMode.Error) throw new UIThreadAccessException(); -#endif } /// diff --git a/test/Eto.Test.Mac/UnitTests/ButtonTests.cs b/test/Eto.Test.Mac/UnitTests/ButtonTests.cs index 1816545b9..adc40ad18 100644 --- a/test/Eto.Test.Mac/UnitTests/ButtonTests.cs +++ b/test/Eto.Test.Mac/UnitTests/ButtonTests.cs @@ -30,7 +30,7 @@ public void ButtonNaturalSizeShouldBeConsistent() var b = new EtoButton(NSButtonType.MomentaryPushIn); var originalSize = b.GetAlignmentRectForFrame(new CGRect(CGPoint.Empty, b.FittingSize)).Size; - Assert.AreEqual(defaultButtonHeight, originalSize.Height, "#2.1"); + Assert.AreEqual((nfloat)defaultButtonHeight, originalSize.Height, "#2.1"); var preferred = handler.GetPreferredSize(SizeF.PositiveInfinity); Assert.AreEqual(originalSize.Height, preferred.Height, "#2.1"); diff --git a/test/Eto.Test/UnitTests/TestBase.cs b/test/Eto.Test/UnitTests/TestBase.cs index 95a7d0690..f45020760 100755 --- a/test/Eto.Test/UnitTests/TestBase.cs +++ b/test/Eto.Test/UnitTests/TestBase.cs @@ -353,6 +353,14 @@ public static void ManualForm(string description, Func ini form.Close(); } }; + form.KeyDown += (sender, e) => + { + if (e.KeyData == Keys.Escape) + { + failButton.PerformClick(); + e.Handled = true; + } + }; row.Cells.Add(failButton); } @@ -361,6 +369,15 @@ public static void ManualForm(string description, Func ini var passButton = new Button { Text = "Pass" }; passButton.Click += (sender, e) => form.Close(); row.Cells.Add(passButton); + + form.KeyDown += (sender, e) => + { + if (e.KeyData == Keys.Enter) + { + passButton.PerformClick(); + e.Handled = true; + } + }; } layout.Items.Add(new StackLayoutItem(table, HorizontalAlignment.Center)); } @@ -458,6 +475,8 @@ public static void ManualDialog(string description, Func var passButton = new Button { Text = "Pass" }; passButton.Click += (sender, e) => dialog.Close(); + dialog.DefaultButton = passButton; + dialog.AbortButton = failButton; dialog.Content = new StackLayout {