Close modal window

Just had a bug bite me in a document window that was like this. I had accidently set it to Document type, meant to set it to moveable modal. The user was able to click on a button more than once which caused other problems. Took a while to get to the source of the problem, because if you ask users, they will say, “Of course I didn’t click on the button twice.”

[quote=246967:@Eli Ott]That will do:

[code]Declare Function standardWindowButton Lib “Cocoa” Selector “standardWindowButton:” (NSWindow As Ptr, windowButtonKind As Int32) As Ptr
Declare Sub setEnabled Lib “Cocoa” Selector “setEnabled:” (NSButton As Ptr, flag As Boolean)

Const NSWindowCloseButton = 0
Const NSWindowZoomButton = 2

setEnabled(standardWindowButton(Ptr(Self.Handle), NSWindowCloseButton), True)
setEnabled(standardWindowButton(Ptr(Self.Handle), NSWindowZoomButton), False)[/code][/quote]

OK. That works. The maximize button has to be enabled, as well as the close button, in the IDE.

Thank you Eli.

The discussion restarted there, where Paul Lefebvre posted a good working declare :
https://forum.xojo.com/31291-force-close-button-to-show-on-cocoa-movable-modal