Home > Software design >  Setting value for title of NSOpenPanel does not work
Setting value for title of NSOpenPanel does not work

Time:07-17

I want to set title for my NSOpenPanel, but it does not work! Apple says:

Gets and sets the title for the panel shown at the top of the window.

But I can not make codes works, not sure what is wrong?

let nsOpenPanel = NSOpenPanel()
    nsOpenPanel.canChooseFiles = true
    nsOpenPanel.title = "Hello, Choose Files"

   if (nsOpenPanel.runModal() == .OK) ... // rest of codes ...

CodePudding user response:

The title is something from the past when windows in macOS had title bars. To show text or an instruction on top of the NSOpenPanel object, use the message property:

nsOpenPanel.message = "Hello, Choose Files"
  • Related