mirror of
https://github.com/coteditor/CotEditor.git
synced 2024-09-11 19:27:30 +03:00
Enable opening folder from open panel
This commit is contained in:
parent
af786b41ec
commit
1b559c22e5
@ -187,6 +187,8 @@ final class DocumentController: NSDocumentController {
|
||||
let accessoryView = NSHostingView(rootView: accessory)
|
||||
accessoryView.sizingOptions = .intrinsicContentSize
|
||||
|
||||
openPanel.delegate = options
|
||||
openPanel.canChooseDirectories = true
|
||||
openPanel.accessoryView = accessoryView
|
||||
openPanel.isAccessoryViewDisclosed = true
|
||||
|
||||
|
@ -28,9 +28,18 @@ import Observation
|
||||
import AppKit.NSOpenPanel
|
||||
import FileEncoding
|
||||
|
||||
@Observable final class OpenOptions {
|
||||
@Observable final class OpenOptions: NSObject, NSOpenSavePanelDelegate {
|
||||
|
||||
var encoding: String.Encoding?
|
||||
var isDirectory: Bool = false
|
||||
|
||||
|
||||
func panelSelectionDidChange(_ sender: Any?) {
|
||||
|
||||
guard let panel = sender as? NSOpenPanel else { return }
|
||||
|
||||
self.isDirectory = panel.url?.hasDirectoryPath == true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -64,6 +73,7 @@ struct OpenPanelAccessory: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
.disabled(self.options.isDirectory)
|
||||
|
||||
Toggle(String(localized: "Show invisible files", table: "OpenPanelAccessory", comment: "toggle button label"), isOn: $showsHiddenFiles)
|
||||
.onChange(of: self.showsHiddenFiles) { (_, newValue) in
|
||||
|
Loading…
Reference in New Issue
Block a user