Home Forums General XMetaL Discussion How do I detect if the cursor is outside of the root element? Reply To: How do I detect if the cursor is outside of the root element?

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

Products
Downloads
Support