Greetings,
in my “database” plugin I have the following startup module to log changes to records. It takes the tiddler to be saved, diffs it against the current version in the store and drops fields that did not change (plus created and modified):
...
exports.name = "snapshot";
exports.after = [ "rootwidget" ];
exports.platforms = [ "browser" ];
exports.synchronous = true;
exports.startup = function() {
$tw.hooks.addHook("th-deleting-tiddler", function(tiddler) { return onChange(tiddler, "d"); });
$tw.hooks.addHook("th-saving-tiddler", function(tiddler) { return onChange(tiddler, "c"); });
};
})();
Wondering why my custom buttons did not trigger the hook, but the default save button does I found this: “the hook is not invoked for tiddlers that are saved through other means”.
So I took <$action-sendmessage $message="tm-save-tiddler"/> from $:/core/ui/EditTemplate expecting the root navigator widget would catch and handle it like the core button but the hook does not get triggered. How can I run my onChange function for custom buttons/action widgets?