Copy link to clipboard
Copied
I noticed today that the "prompt" command appears to have a limit where it can accept no more than 255 characters. If you try to enter more, Photoshop crashes!
Photoshop CC v14.2.1 x64
Windows 7 64-bit SP1
16 GB RAM
I tried the following:
var defaultTextString = "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789.123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789.1234567890123456789012345678901234567890123456789|12345"; | |
var textString = prompt("Enter citation:", defaultTextString); |
With 255 characters in the defaultTextString, the prompt works as expected. If you add an additional character to the defaultTextString, the prompt box comes up as expected with the full default text as expected. However, when you hit the OK button, you get the following Windows error and Photoshop closes.
Adobe Photoshop CC has stopped working
A problem caused the program to stop working correctly.
Windows will close the program and notify you if a solution is
available.
I am relatively new to Photoshop scripting. Is there another command that I should be using for text input larger that 255 characters?
- Brad
Davide,
Thanks for taking the time to reply with the code sample. I tried to copy and paste it into a new window in ExtendScript Toolkit, and I got an error on line 2. Unfortunately, I am not experienced enough yet to find the exact problem. However, you got me pointed in the right direction and I was able to learn a lot about windows!
For the benefit of others, there is windowing code for Photoshop called ScriptUI. I found a helpful tutorial here: ScriptUI for dummies | Peter Kahrel
Fro
...Copy link to clipboard
Copied
Hi Brian,
try using this customized version:
function longPrompt(myText, myCitation) {
var winRes = "dialog { \
preferredSize: [250,150], \
alignChildren: ['fill', 'top'], \
orientation: 'column', \
text: 'Confirm', \
titleText: StaticText {}, \
citationText: EditText { preferredSize: [200, 100], properties: {multiline: true, scrolling: true } }, \
buttonsGroup: Group { \
orientation: 'row', \
alignChildren: ['center', 'top'], \
cancelButton: Button { text: 'Cancel' }, \
confirmButton: Button { text: 'Ok' } \
} \
}"
var w = new Window(winRes);
w.titleText.graphics.font = "dialog:18-Bold";
w.titleText.text = myText;
w.citationText.text = myCitation || "Enter your text"
var result = w.show();
return (result === 1) ? w.citationText.text : false
}
var textString = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus."
var result = longPrompt("Enter citation", textString);
$.writeln(result);
Hope this helps.
Regards
Davide Barranca
---
www.davidebarranca.com
www.cs-extensions.com
Copy link to clipboard
Copied
Ouch. wchar_t text [256]; ... ::GetDlgItemTextW (hwnd, 11, text, 2048); I don't think that will fit! I'll log a bug.
Copy link to clipboard
Copied
Thanks for logging the bug!
Copy link to clipboard
Copied
Davide,
Thanks for taking the time to reply with the code sample. I tried to copy and paste it into a new window in ExtendScript Toolkit, and I got an error on line 2. Unfortunately, I am not experienced enough yet to find the exact problem. However, you got me pointed in the right direction and I was able to learn a lot about windows!
For the benefit of others, there is windowing code for Photoshop called ScriptUI. I found a helpful tutorial here: ScriptUI for dummies | Peter Kahrel
From what I found on the web, the CS2 scripting guide contains some of the most comprehensive documentation for ScriptUI (see Chapter 4): Adobe CS2 Photoshop JavaScript Scripting Reference - JavaScriptReferenceGuide.pdf
- Brad
Copy link to clipboard
Copied
Hi,
my fault, some (invisible) spaces were left after the "\" try this one:
function longPrompt(myText, myCitation) {
var winRes = "dialog { \
preferredSize: [250,150], \
alignChildren: ['fill', 'top'], \
orientation: 'column', \
text: 'Confirm', \
titleText: StaticText {}, \
citationText: EditText { preferredSize: [200, 100], properties: {multiline: true, scrolling: true } }, \
buttonsGroup: Group { \
orientation: 'row', \
alignChildren: ['center', 'top'], \
cancelButton: Button { text: 'Cancel' }, \
confirmButton: Button { text: 'Ok' } \
} \
}";
var w = new Window(winRes);
w.titleText.graphics.font = "dialog:18-Bold";
w.titleText.text = myText;
w.citationText.text = myCitation || "Enter your text"
var result = w.show();
return (result === 1) ? w.citationText.text : false
}
var textString = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus."
var result = longPrompt("Enter citation", textString);
$.writeln(result);
Davide
Find more inspiration, events, and resources on the new Adobe Community
Explore Now