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?
Copy link to clipboard
Copied
Don't know Mac, but you can try something like this...
alert("Your message here...", "Whateveryouwant");
Copy link to clipboard
Copied
Displays a platform-standard dialog containing a short message and an OK button.
alert (message[, title, errorIcon]);
message | The string for the displayed message. |
title | Optional. 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.” |
errorIcon | Optional. When true, the platform-standard alert icon is replaced by the platform-standard error icon in the dialog. Default is false . |
Returns undefined
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 😞
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.
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 ScriptUI Dialog Builder with some tweaks based on Peter Kahrel's "Bible" – Beginning ScriptUI
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)
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
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!
Copy link to clipboard
Copied
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.
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.
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: font
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.
Copy link to clipboard
Copied
Took me a little while but i found it using scriptui-2-16-j.pdf, that PDF is AMAZING!!!! So much info!
After knowing the correct info, when i search that font size 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
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".
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...
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
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.
Copy link to clipboard
Copied
That example link doesnt work, i foudn a User notification dialogs
Using that exact same approach returns an error, even when setup like the example.
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!
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.