Copy link to clipboard
Copied
Hi all,
I have selected group objects then How to select "next object below" frames using javascript in indesign cs3?
Copy link to clipboard
Copied
Hi
I interpreted you request as this figure below.
It works for me IDCS3 OSX 10.6.7
groupobject ( pageitem A-E)
├pageitem A
├pageitem B
├pageitem C
├pageitem D
├pageitem E
1. Current selection is B and run script.
2. C is selected
3. And then, current selection is E and run script.
4. A is selected
// select a pageitem in group object
if (app.selection.length === 0) {exit();};
if (app.selection[0].parent.constructor.name !== 'Group') {exit()};
var current_sel = app.selection[0];
var current_id = current_sel.id;
var parent_group = current_sel.parent;
for (var i=0, iL=parent_group.pageItems.length; i < iL ; i++) {
if (parent_group.pageItems.id === current_id) {// current object
// select next object
if (i+1 < iL) {
parent_group.pageItems[i+1].select();
}
else { // if selected last object, select first object
parent_group.pageItems[0].select();
}
};
};
Copy link to clipboard
Copied
// select next object
if (i+1 < iL) {
parent_group.pageItems[i+1].select();
}
else { // if selected last object, select first object
parent_group.pageItems[0].select();
}
Instead, just use the modulo (remainder) operator, % sign.:
parent_grouppageItems[(i+1)%iL].select()