XMetaL Author Enterprise 22.214.171.124
Should be possible to run on much older versions but not tested. For really old versions the Application-level event macro called "On_Application_Document_Context_Menu" will not exist. In this case you may adjust this to use "On_Context_Menu" and integrate the solution with your document-level customization. None of the other APIs used here are new and have been around for a very long time.
Tested with various DTD-based document types, including DITA, DocBook 5 and the Journalist demo DTD. Specifically not tested with XSD Schemas, though it may function in many cases except possibly for namespaced elements or attributes, for this some adjustments might need to be made as some APIs used here are not "namespace aware".
Although I have tested this with our DITA functionality many users might find it confusing to have these additional items on the context menu as there are already options listed there for editing attributes and inserting elements. This was initially designed more as a demo to adapt and take ideas from rather than to solve a specific author's needs by dropping it into an installation and using it just as it is.
1. Allow authors to access and change attribute values from the context menu, avoiding the need to open and interact with the Attribute Inspector. Otherwise, the functionality may be similar, with the added benefit that you have more screen real-estate displaying your document.
2. Allow authors to insert elements using the context menu. Two functions are provided. One that lists all elements allowed at the current selection (same as the Element List) and one that lists the elements allowed immediately following the current element. In both cases selecting one of the listed elements inserts it.
3. Demonstrate a method for retrieving which item in the context menu was selected (no API is provided for that) and passing that value into a macro (also not normally possible). This demo does not actually pass real values, but instead uses fixed known positions in the context menu (because the items are also built at the same time in the correct order) to obtain a number which is then used to call a macro which in turn calls a function and passes the value to that function. I don't know that this is the "best" way to do this, however, it is the only method I can think of.
XMetaL Author does not support passing parameters to macro. It also does not return a value you can query based on the item selected on the context menu, you may only assign an OnAction value when defining the context menu item. This demo shows how having at least as many macros as there are options the user might allows us to work around that with some fairly tricky code. The good thing is that they can all call the same function and just pass a different value into it that the function can use.
Having so many macros loaded should not cause any issues (in theory), however, if you know the element with the largest number of elements / attributes / enumerated values has less than N values you could remove all the extras if you like.
Before using this script please read the notes and comments in the MCR file (which also includes some legal stuff). Basically, this code is provided as a demo and should be treated as if it were completely untested. I have tested it as best I can, but it has not gone through our regular rigorous test process. You may also wish to adapt this code by altering the script logic itself as you may find that the functionality does not meet the exact needs of your end users, etc.
Please also do not use this script without the permission of the people that maintain your XMetaL installation (if that isn't you). Although the possibility is low given the way I have coded this it could conflict with special customizations or scripts, 3rd party tools or plug-ins, a specific work-flow they have set up and wish you to follow, or any number of other things I cannot even guess at. I would recommend telling them about your wish to have something like this and let them integrate it and test it for you.
1. Unzip attached ZIP file.
2. Place MCR file in the Startup folder of your XMetaL Author Enterprise installation.
3. Restart XMetaL Author Enterprise if already running.
1. Remove MCR file.
2. Restart XMetaL Author Enterprise if already running.
Nothing special is required to run these macros as they do not use anything other than the Windows JScript engine and standard XMetaL Author Enterprise 6.0 APIs.
Warning: Do not use this script with real content until you are satisfied it passes your testing.
1. Open or create a new test document.
2. In either TagsOn or Normal view place cursor inside an element or make a selection then right click or press the "Context Menu" key (special Windows keyboards) or press Shift+F10. Two new menu items should be visible on the context menu called "Insert Element..." and "Attributes for <current element name>..."
3. Select either option and play around with it in various situations.
For Legalese, Modifications, Extending Code, and Known Limitations:
See comments in the MCR file.