My applet’s UI is an enhanced window created with Shane Stanley’s DTP v1.1.3. It currently has a “Quit” button which is used to do some clean up and quit the applet [with an error number -128]. I need a new button to go into the space taken by the Quit button. So, I have been trying to enable the “Quit” menu item, which is greyed out.
First idea I tried was to add this to the DTP library in the showTheWindowAndWaitMainThread handler:
That crashes with: “[NSMenultem validateMenultem]: unrecognized selector sent to instance”.
Another option would be to get the DTP library to report back that the window was closed and treat that as a quit. But, I have two questions: Why is the Quit menu item disabled for an AppleScript applet and is there a way to enable it or any other disabled menu item ?
Thanks.
Model: Mac Studio Max 32GB 24c (Ventura)
Browser: Safari 16.1 (18614.2.9.1.12)
Operating System: macOS 12
I can’t figure how to make it work. I’m really not sure what “target” and “action” mean. But, I’ve tried a variety of code ideas all of which fail “unrecognized selector sent to instance”. My final attempt was this:
set appMenu to (current application's NSApp's mainMenu()'s itemAtIndex:0)'s submenu()
set menuItem to appMenu's itemAtIndex:6
menuItem's enabled:true
menuItem's settarget:me
menuItem's action:terminate()
And elsewhere I added:
to terminate()
if name of current application does not start with "Script" then tell me to quit
end terminate
Googling has revealed a lot of examples and ideas none of which worked. There must be a way to get Quit menu item working but, I can’t find it.
I’m still trying to understand why the ‘Quit’ menu item is disabled in an applet in the first place.
In every applet I have/create, the menu item ‘Quit’ works just fine.
Along with a ‘on quit’ handler in my stay-open applet, it works fine.
What kind of applet is this that the standard ‘Quit’ is greyed out?