General XMetaL Discussion
Qing October 21, 2013 at 1:34 am
On_Document_Open_Complete and On_Document_Activate MacroOctober 21, 2013 at 1:34 amParticipants 2Replies 3Last Activity 9 years, 3 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?Derek Read October 21, 2013 at 6:57 pm
Reply to: On_Document_Open_Complete and On_Document_Activate MacroOctober 21, 2013 at 6:57 pm
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.Qing October 22, 2013 at 1:45 am
Reply to: On_Document_Open_Complete and On_Document_Activate MacroOctober 22, 2013 at 1:45 am
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.Derek Read October 24, 2013 at 8:02 pm
Reply to: On_Document_Open_Complete and On_Document_Activate MacroOctober 24, 2013 at 8:02 pm
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.
- You must be logged in to reply to this topic.