Script Alert - Title - Alert Box

Participant ,
May 10, 2019

Copy link to clipboard

Copied

Ive noticed that when doing something like...

alert("Your message here..."); in Windows, the alert box shows Script Alert as the title but Mac doesn't

Is there anyway to replace the Script Alert with something else or is it just a Windows thing?

TOPICS
Actions and scripting

Views

2.5K

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Script Alert - Title - Alert Box

Participant ,
May 10, 2019

Copy link to clipboard

Copied

Ive noticed that when doing something like...

alert("Your message here..."); in Windows, the alert box shows Script Alert as the title but Mac doesn't

Is there anyway to replace the Script Alert with something else or is it just a Windows thing?

TOPICS
Actions and scripting

Views

2.5K

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
May 10, 2019 0
Advocate ,
May 10, 2019

Copy link to clipboard

Copied

Don't know Mac, but you can try something like this...

alert("Your message here...", "Whateveryouwant");

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 10, 2019 1
Adobe Community Professional ,
May 10, 2019

Copy link to clipboard

Copied

https://estk.aenhancers.com/8%20-%20ExtendScript%20Tools%20and%20Features/user-notification-dialogs....

Global alert function

Displays a platform-standard dialog containing a short message and an OK button.

alert()

alert (message[, title, errorIcon]);

messageThe string for the displayed message.
titleOptional. A string to appear as the title of the dialog, if the platform supports a title. Mac OS does not support titles for alert dialogs. The default title string is “Script Alert.”
errorIconOptional. When true, the platform-standard alert icon is replaced by the platform-standard error icon in the dialog. Default is false.

Returns undefined

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 10, 2019 2
Engaged ,
Dec 18, 2020

Copy link to clipboard

Copied

Ohmygod how horrendous is the Windows dialog compared to OSX.

THe UI is completely off. OSX shows same theme as the app, windows does not. Also uses with margins and ugle ! icon 😞

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 18, 2020 0
Adobe Community Professional ,
Dec 23, 2020

Copy link to clipboard

Copied

It's a platform standard dialog, so you get what you get.

 

You could use scriptUI to create a subjectively better looking alert... At least it will be "more consistent" from Mac to Win.

 

scriptUI-Alert.png

 

Here is a function that can be used once, with a variable call to change the alert text multiple times if needed.

 

https://gist.github.com/MarshySwamp/9b23cfeb128ab6652164d6d87268bc6a

 

 

 

scriptAlert("Alert window title", "Alert text string 1", "Alert text string 2");

function scriptAlert(alertTitle, alertString1, alertString2) {
    var alertWindow = new Window("dialog", undefined, undefined, {resizeable: false});
        alertWindow.text = alertTitle;
        alertWindow.preferredSize.width = 300;
        alertWindow.preferredSize.height = 100;
        alertWindow.orientation = "column";
        alertWindow.alignChildren = ["center", "top"];
        alertWindow.spacing = 25;
        alertWindow.margins = 20;
    var alertText = alertWindow.add("group");
        alertText.orientation = "column";
        alertText.alignChildren = ["left", "center"];
        alertText.spacing = 0;
        alertText.alignment = ["left", "top"];
        alertStringSize1 = alertText.add("statictext", undefined, alertString1, {name: "alertText", multiline: true});
        alertStringSize1.graphics.font = ScriptUI.newFont ("dialog", "BOLD", 13);
        alertStringSize2 = alertText.add("statictext", undefined, alertString2, {name: "alertText", multiline: true});
        alertStringSize2.graphics.font = "dialog:13";
    var okButton = alertWindow.add("button", undefined, undefined, {name: "okButton"});
        okButton.text = "OK";
        okButton.alignment = ["left", "top"];
        okButton.graphics.font = "dialog:13";
    
    alertWindow.show();
}

 

 

 

Edit: I have updated the code to increase the size of the text so that the text size is more legible on Win OS. I'm still trying to work out the correct syntax for the menu title size... Can anybody help?

 

Based on code generated from https://scriptui.joonas.me/ with some tweaks based on Peter Kahrel's "Bible" – Beginning ScriptUI

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 23, 2020 1
Engaged ,
Dec 28, 2020

Copy link to clipboard

Copied

I do notice other differences, the Windows dialog dont get a Photoshop icon whereas OSX dialog do. Below eis example of a basic alert written like this. On OSX when no title or icon is given we get a complete different result vs windows. Windows will add "Dialog alert" in the dialog header and it also adds this ugle exclamation mark icon 😞

alert("Export was succesful.\n"+exportPath)

OSX alert dialogOSX alert dialog

 

I did see other differences as well. Like dropdown menu's in a dialog windows have a scrollbar on windows?!? kinda weird when i have just 3 items!

 

Ill try to update these posts with Windows screengrabs. I dont have both the Windows system on hands now.

 

PS thanks for those link, ill will check them

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 28, 2020 0
Engaged ,
Dec 28, 2020

Copy link to clipboard

Copied

So that basically a dialog window setup used as a custom Alert dialog?!

I know that ScriptUI, since i found that i dont use the manual method anymore. Bizarre it takes an outside to come up with such MARVELOUS implementation for these dialogs.

 

PS i did some work on that custom dialog. Now it does an icon 🙂 I need to think if this is what i need, perhaps users will be funsued by looking at the color of this window. Normally dialogs are graylight gray of color. But still being able to show somehow the same dialog on both OS's i nice!

added icon to the dialogadded icon to the dialog

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 28, 2020 0
Engaged ,
Dec 29, 2020

Copy link to clipboard

Copied

@Stephen_A_Marsh 

 

Thanks again for the code example and links. I did some small work on it. Mainly on Windows, that dialog windows acts so much differently vs OSX.  I dont understand why some of the items get scroll-handles in the Windows dialog versions?!

 

I change some minor parts in the dialog, not really visible. Had a little bit of a fight getting that icon in 😉
I used a linked method but thats not ideal when your sharing scripts. So i now use stringified or binary version of the image. Took me a while to figure that out again.

 

OSX dialog versionOSX dialog versionWindows dialog versionWindows dialog version

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 29, 2020 1
Adobe Community Professional ,
Dec 29, 2020

Copy link to clipboard

Copied

Hi schroef thanks for sharing! Have you worked out how to change the font size or other attributes in the title bar? That has me stumped... Even if not, it would be illustrative if you could post the code for the dialog, thanks.

 

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 29, 2020 1
Engaged ,
Jan 04, 2021

Copy link to clipboard

Copied

Sorry i did noticed the update. When i look at website containing ScriptUI info, i do see font size. When i try apply it, it doesnt change anything. But it also doesnt return an error (error meaning it doesnt know the code)

This is where i looked for the info

https://javascript-tools-guide.readthedocs.io/user-interface-tools/graphic-customization-objects.htm...

 

Its really vague, they show an example and it does not work. Thats what i get a lot with there examples, its so vague how they note information and data.
Screen Shot 2021-01-04 at 11.47.24.png

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 04, 2021 0
Engaged ,
Jan 04, 2021

Copy link to clipboard

Copied

Took me a little while but i found it using this PDF, that PDF is AMAZING!!!! So much info!
After knowing the correct info, when i search that website i also found the info. Though i find the PDF much easier to understand, probably cause the examples are better to understand for me.

 

This is the line i changed

// alertStringSize1.graphics.font = "dialog:13";
        alertStringSize1.graphics.font = ScriptUI.newFont ("dialog", "Bold", 18);

 

Which resulted in this, the string 1 (line1) is now quite bigger

example changed fontsizeexample changed fontsize

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 04, 2021 0
Adobe Community Professional ,
Jan 04, 2021

Copy link to clipboard

Copied

 

Thank you for the reply schroef ,

 

Yes, I also worked that out, you can see that in my previous code, as below:

 

 

.graphics.font = ScriptUI.newFont ("dialog", "bold", 13);
.graphics.font = "dialog:13";

 

 

However, I'm referring to the "title bar" text, in your example the first visible text which you have titled "Search Results". In my screenshot this is "Alert Window Title".

 

title.png

 

Sorry for not being clear.

 

It is OK on the Mac, however, on Win it is a little underwhelming. Just like the dialog text, it just needs to come up to 13pt to make it the same as the Mac's default sizing, which is more ledgible.

 

Looking at the scriptUI information, one can set a global panel font size, or sizing for individual variables. I just don't know if the title bar text is outside of this scope and can't be changed or if I am just coding it wrong.

 

I have noted that the dialog window text that can be changed is a variable, while the title bar text is not a variable.

 

The syntax kills me, so I don't know if this is possible and I'm just messing it up, or I could just be trying to do something that is just not possible...

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 04, 2021 1
schroef LATEST
Engaged ,
Jan 05, 2021

Copy link to clipboard

Copied

Yeah i though you meant the body text, atleast i was thinking you meant that. The title bar normally is a bit harder to do. Since it also shows different on the 2 OS's, that makes it even worse. Th ewindows ScriptUI looks horrible man. I got a Windows machine since a couple weeks and im banging my head sometimes. Last time i worked with Windows was 17 years back, as if nothing changed, still looks like crap 😞

 

Well in your example code, i thought you coded that actaully, the title is also a variable.  But titles cant be edit that much. With a regular dialog Photoshop Mac doesnt get titles i believe. thats why this custom dialog is nice. Concerning the Title, there isnt really much we cn do i believe. Its kinda crappy how everything looks in Windows so this fits right in 😉 hahaha no joke aside. I dont think we can make it centered like on OSX.


EDIT

tried find and see on page 79

Titles cant be changed. Im not sure what we can do on OSX thoughTitles cant be changed. Im not sure what we can do on OSX though

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 05, 2021 0
Engaged ,
Dec 28, 2020

Copy link to clipboard

Copied

Optional. When true, the platform-standard alert icon is replaced by the platform-standard error icon in the dialog. Default is false.

 

Kinda confusing. I also tried this alert approach, but i think there are typos somewhere n there. I returns errors. I believe the comma is at wrong location. I tried a couple variant of this example. But doesnt seem to work properly on OSX.

 

When i use \n in an alert i somehow get a title in the body message of a dialog. The dialog header is not possible like you mention. Though i find this OSX look cleaner vs the Windows approach.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 28, 2020 0
Engaged ,
Dec 28, 2020

Copy link to clipboard

Copied

That example link doesnt work, i foudn a different one 

Using that exact same approach returns an error, even when setup like the example.

code examplecode exampleexample throws errorexample throws error

 

Looking at the example images in that linked page, these guides are really old. I guess thats why its throwing that error in newer PS version. I see that scripting guides states JavaScript for CC, but lots of JavaScript in those guides is more then a decade old, sometimes way older. Its also documented really bad!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 28, 2020 0
Engaged ,
Dec 28, 2020

Copy link to clipboard

Copied

well the error alert message does work if i level out those square brackets completly. Otherwise it keeps spitting out this undefined error.

so now i tried 

alert(message, title, errorIcon);

 

On OSX it works, thought because of title now working on OSX i need to add everything in the message and use \n to make it work in the message part. But i was now able to change the icon on OSX. Lets see how this looks on Windows tonight at home.

 

dialog with or without default icondialog with or without default icon

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 28, 2020 0