General XMetaL Discussion
XMetaL Community Forum › General XMetaL Discussion › MoveToElement() skips thead and rows
-
KdG March 4, 2014 at 10:38 am
MoveToElement() skips thead and rows
March 4, 2014 at 10:38 amParticipants 0Replies 1Last Activity 8 years, 11 months agoXMetaL Author 6.0
I have documents with cals-tables in them.
elements, most
If I run a macro with a simple loop with a rng.MoveToElement() to fill all open id'd the loop skips allelements and the elements from about row 2 and beyond.
Is this a bug? What is wrong here? Is there a solution?To reproduce, run the macro on the demo-table below:
// XMetaL Script Language JSCRIPT:
var rng=ActiveDocument.Range;
rng.MoveToDocumentStart();
var n=0;
while (rng.MoveToElement()) {
if (rng.hasAttribute(“id”) && rng.ContainerAttribute(“id”)==””) {
n++
rng.ContainerAttribute(“id”) = “P”+n;}
}
K
L
M
N
O
A
F
P
20
V
B
G
Q
30
W
C
H
R
40
X
XMetaLOldTimer May 15, 2014 at 9:15 pm
Reply to: MoveToElement() skips thead and rows
May 15, 2014 at 9:15 pmYou'll need to rewrite the code to use XMetaL's DOM APIs instead.
Range and Selection objects are limited to what elements they can select, especially if the requested selection state cannot be made by a user on-screen in Tags On or Normal view. As you are seeing, it is not possible to select a thead programmatically and neither is it possible with a mouse. When attempting to make such a selection, XMetaL will adjust the selection to the nearest location that is selectable on-screen and/or also permits text input like a entry element.
Regards,
Addam -
AuthorPosts
- You must be logged in to reply to this topic.