diff options
author | Jose Medrano <josmed@microsoft.com> | 2022-03-29 18:50:05 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-29 18:50:05 +0300 |
commit | 87b0a435e2f3eec34afc026e9c2eb1448ba6842c (patch) | |
tree | ac09f076f494e65e1e70ca47fc347dcb0a500a94 | |
parent | 13d7a18c5bbc6f882a1850dfa7afb05ee643aa6a (diff) | |
parent | 7015a04bda39a0e16cace7fb98d11cd23bd08e62 (diff) |
Merge pull request #1096 from mono/active-window
[AlertDialogBackend] Ensures parent is set using the active window if there are not any window specified
-rw-r--r-- | Xwt.XamMac/Xwt.Mac/AlertDialogBackend.cs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Xwt.XamMac/Xwt.Mac/AlertDialogBackend.cs b/Xwt.XamMac/Xwt.Mac/AlertDialogBackend.cs index acf66e21..64a4fc52 100644 --- a/Xwt.XamMac/Xwt.Mac/AlertDialogBackend.cs +++ b/Xwt.XamMac/Xwt.Mac/AlertDialogBackend.cs @@ -112,6 +112,19 @@ namespace Xwt.Mac Window.ReleasedWhenClosed = true; if (win != null) return sortedButtons [(int)this.RunSheetModal (win) - 1000]; + + if (win == null) + { + //a modal dialog needs parent window so we try take the current key + win = NSApplication.SharedApplication.ModalWindow ?? NSApplication.SharedApplication.KeyWindow; + } + + if (win != null) + { + win.AddChildWindow(this.Window, NSWindowOrderingMode.Above); + } + + Util.CenterWindow(this.Window, win); return sortedButtons [(int)this.RunModal () - 1000]; } |