Page 1 of 1

Get Currently Selected / Highlghted Text

Posted: Mon Jan 14, 2019 4:06 am
by robustrory
Hey there, I've been wandering around the barren land of documentation for a while now, thought I'd try my hand at asking for help.

I'm trying to get the selected / highlighted text when using the text tool.
I've stumbled across / figured out a lot of the other aspects i need, but I haven't yet figured out how to get the actual selection start and end (text range).
Using the Action Manager / Description world I can iterate over the textStyleRanges, but I don't know how to tell which one is currently highlighted.. I see the 'from' and 'to' of each range, but that's it.

Image

Re: Get Currently Selected / Highlghted Text

Posted: Fri Jan 18, 2019 7:44 am
by robustrory
From the lack of responses and also through my own investigation, I'm thinking this is not possible.
Using the script listener, I see that the changes to the TextItem's From and To properties are passed raw values, not fetched by using an ActionDescriptor:

var idFrom = charIDToTypeID( "From" );
desc169.putInteger( idFrom, 28 );
var idT = charIDToTypeID( "T " );
desc169.putInteger( idT, 40 );

I'd expect the 28 and 40 above to be retrieved in some way if this was possible. 28 and 40 represent the beginning and end of a text range. Essentially, the highlighted section in the screenshot to my last post.

Unless someone knows some way to do it and is willing to speak up, I figured I would leave another post to help anyone reach my conclusion a couple days sooner.

Re: Get Currently Selected / Highlghted Text

Posted: Mon Jan 21, 2019 12:32 am
by Kukurykus
That's not possible as highlighted text make Photoshop waits to commit 'changes' even if you only highlighted text, but didn't start to edit it. Only way to do what you want is to involve external application wrote by for ex. autohotky.com if you are on Windows, are you?

Re: Get Currently Selected / Highlghted Text

Posted: Tue Jan 29, 2019 8:11 am
by robustrory
Hey Kukurykus , thanks for the response. I am on windows.
i noticed there was the "commit" phase for text changes, as well.

When you say:
Only way to do what you want is to involve external application
is this a standard practice for plugin authors?

Re: Get Currently Selected / Highlghted Text

Posted: Thu Feb 07, 2019 8:02 am
by Kukurykus
No, it's not, and it would work for Windows only if you used AHK I mentioned in previous post.