General XMetaL Discussion

XMetaL Community Forum General XMetaL Discussion Event to trigger after macro/command clicked

  • ChrisTMH

    Event to trigger after macro/command clicked

    Participants 0
    Replies 1
    Last Activity 6 years, 7 months ago

    Using XMetaL version:

    I am using a custom toolbar inside XMetaL. I would like to have some code execute whenever any of these macros are clicked/executed, so that I can then check the type of element inserted and mark the “audience” attribute appropriately (for conditional content).

    I did think about simply calling a custom function in the mcr file, but then I'd have to write the code to do so in every macro section, for new macros, etc. – I would prefer inserting code at a common execution point.

    Any ideas how I could do this?



    Derek Read

    Reply to: Event to trigger after macro/command clicked

    There is no specific event designed for what you want to do.

    What you suggest is probably the simplest and most reliable way to do this. Putting the code in a separate function or macro and calling that (as you suggest) would mean you only need to add one line to each of your others.

    One alternative would be to add something to the On_Update_UI event to make the additional change, but you would need additional logic in there to make sure that when this event fires and one of your macros wasn't the trigger that it doesn't do something you don't want to happen. This event isn't really meant for this purpose however. I think this would be messy. It is also recommended that this event contain the smallest amount of code possible as it runs frequently.

    Another option would be to run through all the nodes in your document before saving, in On_Document_Before_Save, and set any values there. This of course means that you can figure out what needs to be added at that time. If that can't be done easily out of context of running the initial macro then you might need to use the ChangedNodes and related APIs to figure out what has been changed (that might not even give you enough context). I don't think that would save you much coding and it would introduce more complexity.


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

Lost Your Password?