• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Select part of string in edit text

Engaged ,
Jun 17, 2015 Jun 17, 2015

Copy link to clipboard

Copied

In photoshop UI using JavaScript: Is this possible?

text_selection.jpg

I've tried using textselection to no avail as that just concatenates the text, I just want to select part of the edittext only.

TOPICS
Actions and scripting

Views

1.8K

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
community guidelines
Adobe
Community Expert ,
Jun 17, 2015 Jun 17, 2015

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():

JavaScript String split() Method

Votes

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
community guidelines
Engaged ,
Jun 19, 2015 Jun 19, 2015

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?

Votes

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
community guidelines
Community Expert ,
Jun 19, 2015 Jun 19, 2015

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.

Votes

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
community guidelines
Participant ,
Jun 21, 2015 Jun 21, 2015

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();

]

Votes

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
community guidelines
Advocate ,
Sep 14, 2017 Sep 14, 2017

Copy link to clipboard

Copied

textselection is broken in CC2017, right?

Votes

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
community guidelines
Community Expert ,
Sep 14, 2017 Sep 14, 2017

Copy link to clipboard

Copied

Hi Tomas Sinkunas​,

textselection is not broken in PS 2017.1.1 20170425.r.252

textSelection_CC2017.png

By the way, Clean SL is very nice.

Votes

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
community guidelines
Advocate ,
Sep 14, 2017 Sep 14, 2017

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 😕

Screen Shot 2017-09-14 at 22.46.20.png

And thanks for supporting Clean SL buddy. glad you like it.

Votes

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
community guidelines
Community Expert ,
Sep 14, 2017 Sep 14, 2017

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

Votes

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
community guidelines
Advocate ,
Sep 14, 2017 Sep 14, 2017

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.

Votes

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
community guidelines
Community Expert ,
Sep 14, 2017 Sep 14, 2017

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.

Votes

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
community guidelines
Engaged ,
Sep 17, 2017 Sep 17, 2017

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

Davide Barranca - PS developer and author
www.ps-scripting.com

Votes

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
community guidelines
Community Expert ,
Sep 17, 2017 Sep 17, 2017

Copy link to clipboard

Copied

LATEST

Yes it a Mac thing is works on windows using the cc 2017 ScriptUI.

Capture.jpg

JJMack

Votes

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
community guidelines