Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/xwt.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJose Medrano <josmed@microsoft.com>2022-03-17 21:17:07 +0300
committerJose Medrano <josmed@microsoft.com>2022-03-18 13:36:13 +0300
commitfbe1d60cc374964d33a2f86cea9ba76d3d9640e9 (patch)
tree239a773e1ddfbfd16ab251ac9c7bd645c758a21a
parentf418a5fe8e5592ae7f1e18964b8875ea676309a7 (diff)
[Xam.Mac] Fixes parenting in DialogBackend
-rw-r--r--Xwt.XamMac/Xwt.Mac/DialogBackend.cs7
-rw-r--r--Xwt.XamMac/Xwt.Mac/Util.cs14
2 files changed, 21 insertions, 0 deletions
diff --git a/Xwt.XamMac/Xwt.Mac/DialogBackend.cs b/Xwt.XamMac/Xwt.Mac/DialogBackend.cs
index a33cf9cd..c50c012b 100644
--- a/Xwt.XamMac/Xwt.Mac/DialogBackend.cs
+++ b/Xwt.XamMac/Xwt.Mac/DialogBackend.cs
@@ -169,6 +169,13 @@ namespace Xwt.Mac
{
Visible = true;
modalSessionRunning = true;
+
+ NSWindow nsParent = parent.Window as NSWindow;
+ if (nsParent != null && nsParent.IsVisible)
+ {
+ nsParent.AddChildWindow(this, NSWindowOrderingMode.Above);
+ }
+ Util.CenterWindow(this, nsParent);
NSApplication.SharedApplication.RunModalForWindow (this);
}
diff --git a/Xwt.XamMac/Xwt.Mac/Util.cs b/Xwt.XamMac/Xwt.Mac/Util.cs
index 3f6f75dd..6093bcda 100644
--- a/Xwt.XamMac/Xwt.Mac/Util.cs
+++ b/Xwt.XamMac/Xwt.Mac/Util.cs
@@ -108,6 +108,20 @@ namespace Xwt.Mac
v.Frame = new CGRect ((nfloat)rect.X, y, (nfloat)rect.Width, (nfloat)rect.Height);
}
+ public static void CenterWindow(NSWindow nsChild, NSWindow nsParent)
+ {
+ if (nsParent != null && nsParent.IsVisible)
+ {
+ int x = (int)(nsParent.Frame.Left + (nsParent.Frame.Width - nsChild.Frame.Width) / 2);
+ int y = (int)(nsParent.Frame.Top + (nsParent.Frame.Height - nsChild.Frame.Height) / 2);
+ nsChild.SetFrameOrigin(new CGPoint(x, y));
+ }
+ else
+ {
+ nsChild.Center();
+ }
+ }
+
public static Alignment ToAlignment (this NSTextAlignment align)
{
switch (align) {