Custom icon in Dialog Toolkit?

Is it possible to add a custom icon ability in the Dialog Toolkit ? I have read that NSAlert by default uses the app icon but I can’t figure out the code that enables that. Instead, I get the icon indicated by “as informational/critical/warning alert” [or Alert Style].

I tried editing Dialog Toolkit by adding:

set appIcon to missing value

and then in the “tell alert”

	its seticon:appIcon

But it returns “unrecognised selector” on NSAlert seticon:




its setIcon:appIcon

Case matters.

Shane, that was quick many thanks !

Changed case on setIcon and no more error. Ran the applet and its icon is now showing.

To get get a custom icon to show, I tried pasting the image into the applet’s “GetInfo”. But that didn’t work. I had to put the custom icon file into “Contents/Resources” and name it “applet.icns”. Logical but a trap for this neophyte.

Another two questions if I may. First, is there a way to define the “cancel button” [except by using the label “Cancel”] as there is in AppleScript’s display dialog ? I would like a “Quit” button that works when the user presses Esc (as it would with Cancel).

Second, the create labeled path control doesn’t seem to update itself if the user selects one of the items in the drop down (e.g. the user’s home folder). However, it does update if the user drags a folder over it or selects “Choose…” and selects a folder. Is that the current behaviour ?


Edited: change to a relevant example in question 2

You can set a key equivalent (using setKeyEquivalent: and setKeyEquivalentMask: — for esc you use command-. However, you probably shouldn’t — users expect esc to mean Cancel.

That’s how the path control has always worked — the menu only displays the path. It’s an old control, not used much these days, but it’s the only way to get file selection in such a dialog.

If you want the escape key as the shortcut for a button not titled “Cancel”, try this:

its setKeyEquivalent:(character id 27)

Shane, ionah, many thanks. As Shane suggested, people will expect Esc to be Escape and not Quit. I’ll try to assign command-q to a Quit function instead.