Home › Forums › General XMetaL Discussion › Override the File> Open menu command › Reply To: Override the File> Open menu command
Reply to: Override the File> Open menu command
March 17, 2009 at 6:48 pmYou should be able to override any built-in shortcut by specifying the same shortcut on your own macro. There is a field specifically for this in the Macro editor's properties window. When the resulting MCR file is built it will contain the following:
[code]
File operation event macros:
You may be interested in the event macros XMetaL Author provides for overriding the standard file operations. They may be useful here because they avoid the need to remove and recreate menu items. You simply create an event macro with one of these specific names and the corresponding functionality (exposed anywhere in the standard UI) is overridden by your own script. These events include:
Command | Macro | COM equivalent |
Open | File_Open | None |
New (menu item) | File_Open_Template | Documents.OpenTemplate(); |
New.New (toolbar) | File_New | Documents.Add(false); |
Save | File_Save | ActiveDocument.Save(); |
Save As | File_SaveAs | ActiveDocument.SaveAs(); |
Save All | File_SaveAll | Documents.Save(); |
Close | File_Close | ActiveDocument.Close(); |
Close All | File_CloseAll | Documents.Close(); |
Exit | File_Exit | Application.Quit(0); |
See the Programmers Guide topic called “File operations” for details.
Note that you must define all behaviors you wish to occur including anything that would normally happen by default. So, if you override “Save” you are responsible for saving the document, either using the ActiveDocument.Save() method, or some other means (such as FSO, ADODB Stream, your own control, etc).