Saturday, September 23, 2017

#1 2017-08-01 02:37:56 pm

rubik
Member
Registered: 2017-05-31
Posts: 5

Is it possible to assign a custom icon to a Dialog Toolkit dialog?

For example:

set {theButton, suppressedState} to display enhanced alert theTitle message theMessage with icon FilePathToTheImageFile as informational alert buttons {"Button 1", "Button 2"} giving up after 0 acc view width 350 acc view height theTop acc view controls {} without suppression

Last edited by rubik (2017-08-01 02:38:31 pm)

Offline

 

#2 2017-08-01 04:15:14 pm

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 3194

Re: Is it possible to assign a custom icon to a Dialog Toolkit dialog?

Starting point :

http://www.macscripter.net/viewtopic.php?id=45556&p=2

Yvan KOENIG running Sierra 10.12.6 in French (VALLAURIS, France) mardi 1 aout 2017 23:15:09

Offline

 

#3 2017-08-01 04:49:22 pm

t.spoon
Member
From:: BFE, Massachusetts
Registered: 2013-01-13
Posts: 202

Re: Is it possible to assign a custom icon to a Dialog Toolkit dialog?

If you'd like my copy of Shane's Dialog Toolkit with a few modified functions, including the ability to use custom icons, you can download it here:

https://www.dropbox.com/s/hkt4m1r9ydwey … d.zip?dl=0

DISCLAIMER: I haven't done anything I'm probably supposed to do about including a license, crediting Shane, etc. etc. in that file. I just dumped something that's supposed to be for internal use on Dropbox, so please only use it for reference and understand that this is Shane's code with just a few modifications I put in that may or may not be done correctly.

Edit: Note that I did not change any existing functions in the library, I only added new ones. So I did not add the custom icon to "display enhanced alert," I added new functions "return enhanced alert" and "show returned alert," and these allow the use of the custom icon.

It's divided into the two parts so the script can modify variables in the alert before displaying it.

Last edited by t.spoon (2017-08-02 12:00:49 pm)


Hackintosh built February, 2012 |  Mac OS Sierra
GIGABYTE GA-Z68X-UD3H-B3 | Core i5 2500k | 16 GB DDR3 | GIGABYTE Geforce 1050 TI 4GB
250 GB Samsung 850 EVO | 4 TB RAID
Dell Ultrasharp U3011 | Dell Ultrasharp 2007FPb

Offline

 

#4 2017-09-10 04:26:23 am

Neophyte
Member
From:: Canberra, ACT, Australia
Registered: 2017-08-20
Posts: 13
Website

Re: Is it possible to assign a custom icon to a Dialog Toolkit dialog?

NSAlert by default will show the icon stored in YourApp/Contents/Resources/applet.icns.  Save your custom images into that file.  A tool like Icon Composer might help.  For that to work add two lines of code to Shane's Toolkit:

    set appIcon to missing value -- located inside the on event handler before "tell alert"
and
    its setIcon:appIcon  -- located inside the "tell alert" group.

Cheers.


Public servants are people too

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)