Home Forums General XMetaL Discussion Move the text cursor between tags Reply To: Move the text cursor between tags

Derek Read

Reply to: Move the text cursor between tags

If the selection is currently inside any of the following will work:

//XMetaL Script Language JScript:
//move selection forwards to Para element
Selection.MoveToElement(“Para”);

//XMetaL Script Language JScript:
//move selection backwards to Para element
Selection.MoveToElement(“Para”,false);

//XMetaL Script Language JScript:
//move a range forward to Para element
var rng = ActiveDocument.Range;
rng.MoveToElement(“Para”);
//(optional), make the range “visible”
rng.Select();

//XMetaL Script Language JScript:
//move a range backwards to Para element
var rng = ActiveDocument.Range;
rng.MoveToElement(“Para”,false);
//(optional), make the range “visible”
rng.Select();

There are many other APIs that could be used depending on your exact needs. If those needs are actually more complex than what you have described here then another solution might be better suited and might include combinations of the following. These are all of the “move a selection” APIs that directly manipulate it that I can think of.

SelectBeforeContainer()
SelectAfterContainer()
MoveRight()
MoveLeft()
SelectElement()
Collapse()
GotoNext()
GotoPrevious()
SelectBeforeNode()
SelectAfterNode()

The following properties might also be useful:
parentNode
containerNode

Not all of those will do what you want directly and will need to be used in combination with each other or with other APIs or properties.

Reply

Products
Downloads
Support