cocoa - NSSavePanel accessoryView: Why doesn't my button appear? -


i creating save panel accessoryview contains single checkbox. can work when create button using:

nsbutton(checkboxwithtitle: "check me", target: self, action: #selector(checkboxselected)) 

but gives me warning particular nsbutton initializer requires macos 10.12 , need support 10.10.

here's savepanel setup:

@ibaction func save(_ sender: nsbutton) {     let savepanel = nssavepanel()     savepanel.accessoryview = accessoryview()     savepanel.runmodal() } 

and here's how create accessory view in sierra

func accessoryview() -> nsview {     let checkbox = nsbutton(checkboxwithtitle: "check me", target: self, action: #selector(checkboxselected))     let view = nsview(frame: nsrect(x: 0, y: 0, width: 400, height: 100))     view.addsubview(checkbox)     return view } 

but doesn't work (the button doesn't appear)

func accessoryview() -> nsview {     let checkbox = nsbutton()     checkbox.setbuttontype(nsswitchbutton)     checkbox.title = "check me"     checkbox.state = 1     checkbox.target = self     checkbox.action = #selector(checkboxselected)      let view = nsview(frame: nsrect(x: 0, y: 0, width: 400, height: 100))     view.addsubview(checkbox)     return view } 

got it.

need use nsbutton.init(frame:)

thanks


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -