XMetaL Tips and Tricks

XMetaL Community Forum XMetaL Tips and Tricks CTM: Events that Run when Surrounding or Changing Elements with Element List

  • Derek Read

    CTM: Events that Run when Surrounding or Changing Elements with Element List

    Participants 1
    Replies 0
    Last Activity 14 years, 5 months ago

    Product(s):
    XMetaL Author 4.0+

    Note: These instructions are meant for developers creating their own customizations for XMetaL Author and should not be used to modify the DITA functionality included with XMetaL Author Enterprise.

    Description:
    You may embed a script in the CTM file that runs when a user inserts an element using the Element List. Using XMetaL Developer these scripts are entered in the “On Insert” section of the properties window for a given element in the CTM file.

    These scripts will [u]not[/u] run when the user has selected the “Change” radio button in the Element List, nor will they run if the user has previously selected content in the document and inserts an element that surrounds (wraps) the current selection with the newly inserted element.

    Using Event Macros to Cover All Bases:
    If you would like to create scripts that run when a user performs any of the three actions mentioned above (insert, change or surround) you may use one of several events provided for use with the ElementList object. Please see XMetaL Developer for detailed descriptions of each of the following event macros:

    • On_ElementList_Insert
    • On_ElementList_Change
    • On_ElementList_Surround
    • On_ElementList_Insert_NoRequired

    Using these events allows you to initiate different behavior depending on the exact action a user has performed. If you find that you want the same script to run for all of these user-initiated actions you may define a function containing that script and call it from these other event macros. That way you will only have a single copy of the main script to maintain.

    To check if the current selection contains content (one or more characters) check the return value of the Selection.IsInsertionPoint property.

    XMAX:
    Note that because XMAX does not provide a built-in Element List the ElementList object is not available in that product. To provide similar functionality will require working with the Element List as implemented for the application you have embedded XMAX in, assuming of course that an Element List has been implemented.

    Reply

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

Lost Your Password?

Products
Downloads
Support