1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-10-20 02:07:38 +00:00

Add support for assigning action widgets via the actions attribute

This is quite a big change: a new way to invoke action widgets.

The advantage is that it solves #2217 and #1564, a long running problem
that prevented us from adding action widgets to widgets that modify the
store.

This commit adds the new technique for the button and keyboard widgets,
but also extends the select widget to trigger action widgets for the
first time
This commit is contained in:
Jermolene
2016-04-29 18:53:23 +01:00
parent b53f4e9b20
commit 3c20f2396e
8 changed files with 69 additions and 11 deletions

View File

@@ -504,6 +504,23 @@ Widget.prototype.invokeActions = function(triggeringWidget,event) {
return handled;
};
/*
Invoke the action widgets defined in a string
*/
Widget.prototype.invokeActionString = function(actions,triggeringWidget,event) {
actions = actions || "";
var parser = this.wiki.parseText("text/vnd.tiddlywiki",actions,{
parentWidget: this,
document: this.document
}),
widgetNode = this.wiki.makeWidget(parser,{
parentWidget: this,
document: this.document
});
var container = this.document.createElement("div");
widgetNode.render(container,null);
return widgetNode.invokeActions(this,event);
};
Widget.prototype.allowActionPropagation = function() {
return true;