Kevin Flynn wrote: > My file, save function now looks like this: > > <cfg:command name="mydoc.save"> > <cfg:macro> > <cfg:sequence> > <cfg:pass><cfg:command name="XXE.save" /></cfg:pass> > <!-- do something before saving --> > <cfg:command name="XXE.save"/> > </cfg:sequence> > </cfg:macro> > </cfg:command> > > If I add it to the "XXE" menu then it behaves as I would expect: it is > disabled if the document is unmodified, but enabled as soon as a change > has been made. > > If I add it to the File menu as follows: > > <action name="mydocSaveAction" label="_Save" > icon="xxe-gui:app/icons/saveAction.gif" accelerator="mod S"> > <context editingContextSensitive="false"> > <configuration name="mydoc"> > <command name="mydoc.save"/> > </configuration> > <default> > <class>com.xmlmind.xmleditapp.kit.part.SaveAction</class> > </default> > </context> > </action> > Then it is never enabled. > > If I remove the <cfg:pass><cfg:command name="XXE.save" /></cfg:pass> > element, then it is always enabled. > What is wrong?
Try with editingContextSensitive="true". editingContextSensitive has nothing to do with saving documents. However I *think* (I'm not sure) that this why "mydoc.save" *appears* to work when added to the "XXE" menu: all commands/macro-commands are editingContextSensitive by default when used as actions in the GUI of XXE. --- PS: I understand what you want to do and why you try to do it that way. It may work (in most cases) or it may not. But I need to stress the fact that this is not the right way to intercept opening/closing/saving documents. Today, the right way to do this is to write a DocumentHook (or an OpenedDocumentHook -- http://www.xmlmind.com/xmleditor/_distrib/doc/api/com/xmlmind/xmleditapp/kit/OpenedDocumentHook.html) in the Java[tm] language. And yes, we remember very well your RFE (http://www.xmlmind.com/xmleditor/wish_list.html): --- Support of commands, generally macro-commands, which are automatically executed when a document is opened or saved. Writing such macro-commands would be much easier than programming a DocumentHook in JavaTM. It would be useful if there were two macros associated with each operation: one to be executed before the open/save operation, and one after. In the case of a save operation, for example, the ``before'' macro would have access to XXE's internal functions for manipulating the document, while the ``after'' macro would be able to carry out post processing on the saved document (initiate XSL transformations, execute perl scripts, etc.). --- Note that contextual actions have not been created to solve the above problem. The above problem -- intercepting opening/closing/saving documents without having to write Java[tm] code -- is still unsolved.