Swift OSX NSOpenPanel not changing selection

140 views Asked by At

I am calling a NSOpenPanel so the user can select a file, but after the first selection is done the panel doesn't allow me to change the file when I click with the mouse on another file. It changes when I use the keyboard arrows but it doesn't when I click with the mouse.

@IBAction func selecionarImagemButtonClicked(_ sender: NSButton) {

    let panel = NSOpenPanel()
    panel.allowsMultipleSelection = false
    panel.canChooseDirectories = false
    panel.canChooseFiles = true
    panel.canCreateDirectories = false
    //panel.allowedFileTypes = ["jpg","png","pct","bmp", "tiff"]
    panel.allowedFileTypes = NSImage.imageTypes()

    panel.beginSheetModal(for: view.window!) { (result) in

        if result == NSFileHandlingPanelOKButton {
            self.logoFornecedorImageView.image = NSImage(byReferencing: panel.url!)

            self.logoFornecedorSelecionada = true
        }
    }
}
0

There are 0 answers