Home › Forums › General XMetaL Discussion › Undo in XMAX 5.5 › Reply To: Undo in XMAX 5.5
Reply to: Undo in XMAX 5.5
February 18, 2010 at 5:20 amUntil we figure out a way to do some sort of beginUndo/endUndo, one option I can offer still requires invoking a XMAX macro…but that macro in turn just calls back into your code. Your code can then do a series of mutation (i.e. external COM calls on XMAX). Since those calls are still executed in the context of a macro, XMAX will log all the mutations as a group-command internally…that means the mutations will roll back with a single Undo call or Ctrl-Z.
Roughly, the implementation could go like this assuming MSIE is the XMAX container:
1. Implement the dispatcher macro that calls an object method of your
making.
xmaxContainerCmd.doIt(); // You define the method signature (i.e. interface)
xmaxContainerCmd = null;
]]>
2. Implement IXMetaLControlEvents::OnQueryService(BSTR serviceName, DispRefVar* service)
// MSIE Automagic event bind XMAX COM event sink to MSIE container,
// assumes OBJECT id=”XMAX”
function XMAX::OnQueryService(name, service)
{
switch (name) {
case “YOURNEXTCMD”:
var yourCmd = new Object;
yourCmd.doIt = function() {
// Notice the “doIt” signature here must match
// what you wrote in the XMAX dispatcher.
//
// Write your XMAX calls here or delegate as needed
};
service.Value = yourCmd;
break;
}
}
The same pattern can be replayed in any XMAX container application provided you can provide an IDispatch callable object for the XMAX macro.
Regards,
Addam