General XMetaL Discussion

XMetaL Community Forum General XMetaL Discussion On_Document_Open_Complete and On_Document_Activate Macro

  • Qing

    On_Document_Open_Complete and On_Document_Activate Macro

    Participants 2
    Replies 3
    Last Activity 8 years, 11 months ago

    Hi all, I met some problem with On_Document_Open_Complete and On_Document_Activate Macro run sequence and condition.

    When open a new document and it is not included in the opened xmetal windows, the on_document_open_complete macro runs after the on_document_activate macro.
    But switching between opened documents, it only trigger the on_document_activate macro.

    I debugged my own code but no conditions information was found, would you guys help with the run condition and sequence of the macros?

    Reply

    Derek Read

    Reply to: On_Document_Open_Complete and On_Document_Activate Macro

    Assumption: you are running XMetaL Author Essential

    On_Document_Open_Complete fires as part of the document opening sequence, which occurs when the document is opened from disk by a user (including templates), or when using the Documents.OpenString() API, or other APIs that open documents. If the file is already open this event should never fire again for that document. I assume this is your issue.

    Reply

    Qing

    Reply to: On_Document_Open_Complete and On_Document_Activate Macro

    Thanks you Derek. This explains a lot. I am using XMetal Author Essential.
    Actually my confusion comes from some unclear, or may wrong code. A opened document is not disposed when close it. Then when reopen it, only the macro On_Document_Activate is fired and On_Document_Open_Complete never runs, but, after I change the code to dispose the document when close it, the On_Document_Open_Complete runs after On_Document_Activate.  So I am wondering if some conditions exist.

    Plus anther question, We customize the Command bar to add some other buttons, and according to the state the document to decide the enable the button or not, but it seems that the effect is not shown until mouse click. It makes sense in some situations, but some others not. Is there any API to refresh the command bar? I scanned the programmer's guide but no such API was found.

    Appreciate you time and thank you very much.

    Reply

    Derek Read

    Reply to: On_Document_Open_Complete and On_Document_Activate Macro

    If you wish to disable menu items the best solution is to disable the macro that they are linked to. If you do that then anything in the UI (menu item or toolbar button) will be disabled. The API for this is DisableMacro(“macroname”) and should be used in the On_Update_UI event.

    Reply

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

Lost Your Password?

Products
Downloads
Support