Copy link to clipboard
Copied
Hi everyone,
I was wondering if it is possible via javascript to change the highlighted selection via javascript?
here's an example, we can imagine this layout, which has a selection (some parts of second paragraph):
Is it possible via a javascript to change the displayed selection with the first paragraph instead without using the mouse, like this:
I didn't find anything working for now…
thanks everyone 🙂
Nicolas
Nevermind, I found the solution, here it is if it could help someone else:
[your item].showText()
Have a nice day 🙂
Nicolas
Copy link to clipboard
Copied
Hi everyone,
I was wondering if it is possible via javascript to change the highlighted selection via javascript?
here's an example, we can imagine this layout, which has a selection (some parts of second paragraph):
Is it possible via a javascript to change the displayed selection with the first paragraph instead without using the mouse, like this:
I didn't find anything working for now…
thanks everyone 🙂
Nicolas
Nevermind, I found the solution, here it is if it could help someone else:
[your item].showText()
Have a nice day 🙂
Nicolas
Copy link to clipboard
Copied
Nevermind, I found the solution, here it is if it could help someone else:
[your item].showText()
Have a nice day 🙂
Nicolas
Copy link to clipboard
Copied
Hi Nicolas,
your code cannot work.
What exactly should [your item] stand for?
To make that work you first have to calculate what exactly is selected.
You also want to know what the parent of the selection is.
Regards,
Uwe Laubender
( ACP )
Copy link to clipboard
Copied
Hey Uwe!
I should have writtent a more specific example:
app.selection[0].paragraphs[-1].insertionPoints[-1].paragraphs[-1].showText()
1. In the example below, you have to select a paragraph.
2. Run the script
3. The displayed selection (in indesign not in javascript) will be the next paragraph just after your selection.
All the best,
Nicolas
Copy link to clipboard
Copied
There’s also select()
app.selection[0].paragraphs[-1].insertionPoints[-1].paragraphs[-1].select();
The difference between the showText() and selection() might matter. The showText() method can change the active page as well as make the selection. If your text selection is on page 1, and your activePage is page 10, showText() will make the selection and change your activePage view to page 1—select() will only make the selection.
Copy link to clipboard
Copied
Hello Rob!
Thanks for the precision, that will be usefull aswell.
Nicolas
Copy link to clipboard
Copied
Hi Nicolas,
thank you for your explanation.
Now your posted code is working as expected when I look at your screenshot.
But also test your script on selected text that covers parts of the last paragraph of a story.
Test two cases:
[1] A paragraph character is applied as the last character in the story.
[2] No paragraph character is applied as the last character in the story.
Regards,
Uwe Laubender
( ACP )
Copy link to clipboard
Copied
Hello Uwe,
Did you mean to test before if the next paragraph exists before triying to show it?
Cheers,
Nicolas
Copy link to clipboard
Copied
🙂
First test the two cases and then draw conclusions.
Best,
Uwe Laubender
( ACP )