XMetaL Tips and Tricks
Derek Read October 31, 2008 at 9:16 pm
CTM: Events that Run when Surrounding or Changing Elements with Element ListOctober 31, 2008 at 9:16 pmParticipants 1Replies 0Last Activity 14 years, 1 month ago
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.
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:
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.
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.
- You must be logged in to reply to this topic.