0

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
        }
    }
}
Charles Srstka
  • 16,665
  • 3
  • 34
  • 60
GuiDupas
  • 1,681
  • 2
  • 22
  • 44
  • https://stackoverflow.com/questions/28008262/detailed-instruction-on-use-of-nsopenpanel/28015428#28015428 – Leo Dabus Sep 11 '17 at 21:41
  • Why are you using the modal sheet? Have you read other topics on NSOpenPanel? – El Tomato Sep 12 '17 at 02:06
  • By "after the first selection is done", do you mean click and click again or choose a file and run the panel again? Does clicking on buttons work? I tried your code and can't reproduce the issue. – Willeke Sep 12 '17 at 10:50
  • Yes, I have read the other topics of NSOpenPanel including `Detailed instruction on use of NSOpenPanel` as suggested by Leo Dabus. – GuiDupas Sep 12 '17 at 16:59
  • Willeke, I mean click on a file and after that try to click on another file without closing the Panel. – GuiDupas Sep 12 '17 at 17:00

0 Answers0