General XMetaL Discussion
XMetaL Community Forum › General XMetaL Discussion › How do I detect if the cursor is outside of the root element?
-
scotth August 15, 2011 at 12:53 pm
How do I detect if the cursor is outside of the root element?
August 15, 2011 at 12:53 pmParticipants 2Replies 3Last Activity 11 years, 5 months agoWorking 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.
Derek Read August 15, 2011 at 5:17 pm
Reply to: How do I detect if the cursor is outside of the root element?
August 15, 2011 at 5:17 pmThe 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]
[/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();
}
}
]]>As written, it allows an author to select, edit and remove things that are outside the root (comments and PIs for example).
scotth August 15, 2011 at 7:39 pm
Reply to: How do I detect if the cursor is outside of the root element?
August 15, 2011 at 7:39 pmSadly, 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.
scotth August 15, 2011 at 8:06 pm
Reply to: How do I detect if the cursor is outside of the root element?
August 15, 2011 at 8:06 pmI 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.
-
AuthorPosts
- You must be logged in to reply to this topic.