Fix openFilePanel and openSavePanel #37

This commit is contained in:
Kirurobo
2021-12-12 09:58:28 +09:00
parent b9312ca3a1
commit 2178646873
3 changed files with 15 additions and 12 deletions

View File

@@ -282,7 +282,7 @@ public class LibUniWinC : NSObject {
/// Find my own window
private static func _findMyWindow() -> NSWindow {
let myWindow: NSWindow = NSApp.orderedWindows[0]
let myWindow: NSWindow = NSApp.orderedWindows.first!
return myWindow
}
@@ -980,12 +980,13 @@ public class LibUniWinC : NSObject {
// Temporarily disable always on top in order to show the dialog
targetWindow?.level = NSWindow.Level.floating
}
//  panel.parent accessoryView
// Set attached window as the parent
panel.parent = targetWindow
//panel.parent = targetWindow
} else {
// Find my window if the window is not attached
let myWindow: NSWindow = NSApp.orderedWindows[0]
panel.parent = myWindow
//let myWindow: NSWindow? = NSApp.orderedWindows.first
//panel.parent = myWindow
}
panel.allowsMultipleSelection = PanelFlag.AllowMultipleSelection.containedIn(value: ps.flags)
@@ -994,8 +995,9 @@ public class LibUniWinC : NSObject {
panelHelper.addFileTypes(text: getStringFromUtf16Array(textPointer: ps.filterText))
panel.isAccessoryViewDisclosed = true // Options
panel.message = getStringFromUtf16Array(textPointer: ps.titleText)
panel.message = getStringFromUtf16Array(textPointer: ps.titleText)
//panel.title = getStringFromUtf16Array(textPointer: ps.titleText)
if (initialDir != "") {
panel.directoryURL = URL(fileURLWithPath: initialDir, isDirectory: true)
} else if (initialFile.deletingLastPathComponent != "") {
@@ -1062,12 +1064,13 @@ public class LibUniWinC : NSObject {
// Temporarily disable always on top in order to show the dialog
targetWindow?.level = NSWindow.Level.floating
}
//  panel.parent accessoryView
// Set attached window as the parent
panel.parent = targetWindow
//panel.parent = targetWindow
} else {
// Find my window if the window is not attached
let myWindow: NSWindow = NSApp.orderedWindows[0]
panel.parent = myWindow
//let myWindow: NSWindow = NSApp.orderedWindows[0]
//panel.parent = myWindow
}
panel.parent = targetWindow // Nil if not attatched