General XMetaL Discussion

XMetaL Community Forum General XMetaL Discussion Move the text cursor between tags

  • bjorn

    Move the text cursor between tags

    Participants 0
    Replies 1
    Last Activity 8 years, 7 months ago

    Hi.

    In my macro I need to move the text cursor from one tag to its parent tag.

    I got the name of the tag I what to move to, but can't figure out how to move the text cursor it self.

    When the text cursor is inside the 'Link' tag I want to move the text cursor to the 'Para' tag in code.

    Definitions
                Pt.4

    Its possible that I have to use the rng.SelectElement();  or rng.MoveToElement('Para');.
    But can't figure it out.

    Using XMetaL(R) Author Enterprise 8.0 Service Pack 1

    thanks!

    Reply

    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

  • You must be logged in to reply to this topic.

Lost Your Password?

Products
Downloads
Support