Copy link to clipboard
Copied
In photoshop UI using JavaScript: Is this possible?
I've tried using textselection to no avail as that just concatenates the text, I just want to select part of the edittext only.
Copy link to clipboard
Copied
The result of the prompt box should be saved to a variable. So once the user enters the info and clicks OK, you use a string function to split the string to capture what you want, like substr():
JavaScript String substring() Method
Or split():
Copy link to clipboard
Copied
I'm familiar with substring but how does that relate to the part of the text that's been selected. All I seem to get returned from teh edittext is the whole thing. I just want the part that's been selected (in the case above "bananas").
Can you show me an example?
Copy link to clipboard
Copied
It all depends upon what you want to select. Are you always going to be selecting the word bananas, or will it be the last work, or something else? Depending on what you're trying to isolate dictates what function you will use to get that result. Maybe a search for a certain work, or a split function to get the last word in the string, etc.
Copy link to clipboard
Copied
This is possible :
[
// MAC Finder or WINDOWS Explorer
#target photoshop
app.bringToFront();
var subject="EditText Selection";
var dlgBox = new Window('dialog',subject);
var selection="";
var editTxt=dlgBox.add('edittext {text:"This is bananas !", justify: "left", active: true}');
// Bouton exécution OK
var buttonOk = dlgBox.add ("button", undefined, "OK");
var buttonCancel = dlgBox.add ("button", undefined, "Cancel");
buttonOk.onClick = function()
{
selection=editTxt.textselection;
alert(selection);
}
dlgBox.center();
dlgBox.show();
]
Copy link to clipboard
Copied
textselection is broken in CC2017, right?
Copy link to clipboard
Copied
Hi Tomas Sinkunas​,
textselection is not broken in PS 2017.1.1 20170425.r.252
By the way, Clean SL is very nice.
Copy link to clipboard
Copied
Weird.
This must be Mac thing then. I'm on same Photoshop version as you are.
I select some text, hit OK (using above example), highlight goes away and it alerts empty string 😕
And thanks for supporting Clean SL buddy. glad you like it.
Copy link to clipboard
Copied
https://forums.adobe.com/people/Tomas+Sinkunas schrieb
Weird.
This must be Mac thing then …
Absolutly possible, I think.
https://forums.adobe.com/people/Tomas+Sinkunas schrieb
… And thanks for supporting Clean SL buddy. glad you like it.
Thank you for developing and sharing. You know the user Kukurykus​? He made a smaller version on ps-scripts.com He found
"I found these charIDToTypeID "Avrg", "BeIn", "BeNu", "BeS6", "BkDi", "BkDp", "BkDs", "BkIb", "BkIc", "BkIr", "BkIs", "BkNa", "BkNm", "BkNt", "BkSb", "BkSt", "Bokh", "BtDi", "BtIs", "BtNt", "GEfc", "GEfk", "GEft", "LqFy", "VnPt" dont' have equivalent stringIDToTypeID. There are probably more of them but fortunately that wasn't needed search for them all to make script working properly if it finds their "buddies"."
And perhaps you see some interesting things in https://www.ps-scripts.com/viewtopic.php?f=51&t=24469&p=152882#p152882
Copy link to clipboard
Copied
Yeap, I saw that code. I tried it - it's didn't work. When it actually worked - I didn't like it, as it worked only with last log. Very limited. So I went and build my stuff.
Anyways, back on topic - yeap, hard to admit, but it's a Mac thing. It also doesn't work on After Effect either.
Copy link to clipboard
Copied
Yes it's limited. And it works only on Windows. But after running this script every CC-Version crashes.
Otherwise - the idea was great in Dec 2016.
Copy link to clipboard
Copied
It got broken (on Mac) in the switch from Flash to Mondo as the PS ScriptUI rendering engine – in other words, it works on CC 2014 and it doesn't from CC 2015 onwards – I'll log a bug on that one.
Davide
Copy link to clipboard
Copied
Yes it a Mac thing is works on windows using the cc 2017 ScriptUI.