Add capability for widgets to trigger all descendant action widgets, rather than just immediate children.

Preserves compatibility with existing invokeActions call in button widget by creating a separate 'invokeActionCall' function to carry out the recursion.  Triggering all descendants permits use of action widgets inside list widgets or macros.  Also makes it possible to add triggering capability to select widget.
print-window-tiddler
ng110 2015-01-20 12:34:24 +00:00
rodzic 7d6769f6fd
commit f9c4f6898e
1 zmienionych plików z 13 dodań i 3 usunięć

Wyświetl plik

@ -476,15 +476,25 @@ Widget.prototype.removeChildDomNodes = function() {
};
/*
Invoke any action widgets that are immediate children of this widget
Invoke any action widgets that are descendants of this widget.
*/
Widget.prototype.invokeActions = function(event) {
return this.invokeActionCall(this, event);
};
/*
Recursively search through descendants, invoking all actions encountered.
*/
Widget.prototype.invokeActionCall = function(here, event) {
var handled = false;
for(var t=0; t<this.children.length; t++) {
var child = this.children[t];
for(var t=0; t<here.children.length; t++) {
var child = here.children[t];
if(child.invokeAction && child.invokeAction(this,event)) {
handled = true;
}
if(this.invokeActionCall(child, event)) {
handled = true;
}
}
return handled;
};