General XMetaL Discussion

XMetaL Community Forum General XMetaL Discussion How do I detect if the cursor is outside of the root element?

  • scotth

    How do I detect if the cursor is outside of the root element?

    Participants 2
    Replies 3
    Last Activity 11 years, 1 month ago

    Working with xmax 6.0, I happened to notice that the selection object is not getting updated when I click outside of the root element (i.e. at the very beginning or very end of the document). How can I detect that it has been placed outside of the root element? I noticed that XMetaL forces the cursor back inside the root element when you click outside of it, and I would like to do the same thing, if possible.

    Reply

    Derek Read

    Reply to: How do I detect if the cursor is outside of the root element?

    The value for the nodeName for the whole document is $DOCUMENT.

    However, the macro that does this in XMetaL Author uses a different strategy. That macro is in the xmetal.mcr in the Macros folder in XMetaL Author Essential and Enterprise.

    Here's a copy (note that the first comment is outdated and incorrect, though it does not apply to XMAX anyway):

    [code]
    // this will only work if no On_Update_UI macro is defined for the DTD
    if (Selection.IsInsertionPoint && ActiveDocument.ViewType == 1) {
    // this should only apply to the tags-on view, and allow selection of the top-level element
      if (Selection.ContainerNode == null) {
          Selection.MoveRight();
      }
      if (Selection.ContainerNode == null) {
          Selection.MoveLeft();
      }
    }
    ]]>
    [/code]

    As written, it allows an author to select, edit and remove things that are outside the root (comments and PIs for example).

    Reply

    scotth

    Reply to: How do I detect if the cursor is outside of the root element?

    Sadly, Selection.ContainerNode is still pointing to the previously selected node when I click outside of the root element in tags-on view. Granted, this is in XMAX, so I don't know if that makes a difference. I will keep digging to see if I can come up with any possible solutions.

    Reply

    scotth

    Reply to: How do I detect if the cursor is outside of the root element?

    I take back my previous comment. I must have been looking at one of my own objects that was not in sync with the XMAX control. After revisiting my code, I was able to implement the solution you presented.

    Reply

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

Lost Your Password?

Products
Downloads
Support