Detecting highlighted text in a file

hi all,

is it possible to be able to detect words highlighted in a text file? for instance, if i select “who” in text file, would i be able to save “who” in a variable?

thanks in advance,
destro

1 Like

I‘m not sure if this is what you Need, But you can Indeed detect highlighted Text within the processing Editor, but if this works in external Files… i don‘t know. And you can also add a Variable inside the Editor, by just adding Strings to the Editors Text. For example you could add to the first line of the Code the strings („int “ + name + „ = 0;“). This method is also used by the Formatter in the IDE, But as far as i‘m Aware of it can only be used by tools, not by a Sketch, But that might not be the case. I‘ll Look Up where the methods i‘m Talking about are and edit the post then^^ What i‘m Talking about is JavaTextarea.getDocument().insertString(int pos, int pos end, String text, null); You‘ll have to Look up the exact usage and all It’s methods to get it to do what you Need exactly.

1 Like

i haven’t been successful at figuring out where to start with this.

thanks, i’ll check out this function.

destro

BTW, it Starts from the Editor class, so it‘s more like Editor.getJavaTextArea(). And so on.

i found what i was looking for with your nudge function:

thanks!
destro.

1 Like

Glad i could help you :wink: