Is it possible to edit the font weight and font size from a PS prompt alert dialog?
For example in the following example can, the Report Comment heading display in bold letters?
No. Use ScriptUI.
@Polycontrast – Using the default system alert, prompt and confirmation windows is convenient, however, they are dependent on the OS in use. On the Mac, prior to Big Sur, the dialog widows presented the information in a serviceable fashion and they also looked clean, as your screenshot above illustrates.
Now, take a look at the same code in Big Sur:
As one is using the default OS style, you are at the mercy of either Apple or Microsoft's styling decisions:
Using ScriptUI, one has more control and at least the result is more consistent between different operating systems and versions of the same operating system.
Here is the same code on the Mac, then Windows:
Haha, same code – two different results!
Looks like on Windows, it is truncating the text from "string" to "strin"...
Edit: OK, I just had to add a line of code to set the preferredSize.width as Windows appears to need this, when the Mac does not.
Thank you for the explanation. That is a big difference between the OS prompt dialogs. The script UI has an advantage over the default OS dialogs in terms of uniformity. A better solution is to create the dialog using the script UI. I am unsure how to call the script UI instead of the prompt alert.
Does this make sense?
1. Create the dialog using the scriptUI.
2. Wrap the UI in a function.
3. Call the UI function instead of the prompt alert,
4. Pass the parameters to the UI function
5. Get the user input
That is it. This is why I have been working on this as a "side project" community service. It should be a no brainer, why re-invent the wheel? If it is complex, challenging and frustrating for me, surely it has been for others in the past and will also be for others in the future!
This is just a replacement for "basic" UI windows, not a whole custom script interface such as one may find in say Image Processor Pro.
As luck would have it, I (think) that am almost at the end of this project.
You can find the code for the Alert here:
I'll post the Confirmation and Prompt code soon.
Thank you for providing the link and samples. Now, I have a better idea of how to think about alert boxes and what it takes to stylize the elements of the alert box.
Your welcome! I think (hope) that I have ironed out the creases in the Confirmation and Prompt scripts.
I have not worked with ScriptUI much and generally prefer to avoid it where possible.
I'll give them one final round of testing and post them tonight.
What's wrong with ScriptUI you're trying to avoid it?
What's wrong with ScriptUI you're trying to avoid it?
Let's say that I develop a script that works well without a GUI, perhaps this is based off existing code and I have to add or remove various bits... This may total up to say 3 hours of development time (coding, testing, finding fixes or workaround etc). This may work OK, but may be better off with a scriptUI interface.
Now even with the fantastic UI builder site from Joonas and the dummies guide from Peter Kahrel, it could increase the extra time to develop a script many times from the original time taken to write the script without GUI. So now a project that initally took 3 hours may blow out 9 or more hours.
This is likely a reflection of my current level of knowledge and experience. It is very frustrating to perhaps spend 6 or more hours trying to get a button to do something, researching, deciphering cryptic forum posts etc. It's a bit like starting to learn scripting all over again, which I guess it is in some ways, just with less resources than before.
I'm a self taught enthusiast and this is a hobby, nobody forces me to do this, so I shouldn't be clock watching, but it is painful to spend so much time spinning my wheels when the answers are often so close but out of reach.
The script UI works well, It takes more work to set it up but produces uniform results and offers more styling controls over the default OS alert box. I will try it when a window of time to experiment. Thanks for your recommendation!
Thank you for that, I replied in the linked topic, at least I have multiple options!
That was to Original Poster 😉
To see who the post is answered to you may temporarily switch View to Linear.
The trick on Windows is also to add shortened space character after last letter to see full length of string.
I tried with a regular space character after the text, the line was still truncated. What is a "shortened space character"?
If it makes any difference, the text is being passed from a parameter in a function to a variable for the statictext.
Ah, a "non-breaking space character". This is obvioulsy a known issue, thanks!
As a learning exercise and to give new scripters such as myself a headstart, I have been making Script UI configurable versions of the standard "user notification dialogs" (Alert, Prompt, Confirmation).
What do I mean by configurable? Simply that I have put the UI into a function, replaced statictext.text with variables, then one can replace the variables as needed when calling the function with parameters. This makes the code reusable as one may use these features multiple times in a larger script.
Script UI - Alert:
Script UI - Confirmation:
Script UI - Prompt:
Although an icon/picture could be included, I decided against this to keep the code concise