General XMetaL Discussion

XMetaL Community Forum General XMetaL Discussion Move cursor inside node from selection

  • MrPaul

    Move cursor inside node from selection

    Participants 1
    Replies 2
    Last Activity 9 years, 6 months ago

    Consider the following XML:


    sedan

    If the selection is currently on the entirety of element:

    sedan

    How do I move the cursor directly after the [s]element[/s] tag?

    Note: Selection.ContainerNode is . I want the ContainerNode to be . I am using XMAX v6.

    Reply

    Derek Read

    Reply to: Move cursor inside node from selection

    There would be quite a few ways to do this. Here are a couple of the simplest. You might need additional code if your selection is not always guaranteed to be as you have described it.

    Assuming you meant “directly after the tag” (not “element”, which would put it after the tag) this should do it:
    Selection.Collapse(sqCollapseStart);
    Selection.MoveRight();

    This would result in the same selection:
    Selection.Collapse(sqCollapseStart);
    Selection.MoveToElement("car");

    As would this:
    Selection.Collapse(sqCollapseStart);
    Selection.MoveToElement("");

    And so would this:
    Selection.MoveToDocumentStart();
    Selection.MoveToElement("car");

    Reply

    MrPaul

    Reply to: Move cursor inside node from selection

    Informative, thank you.

    Reply

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

Lost Your Password?

Products
Downloads
Support