diff --git a/core/modules/widgets/action-sendmessage.js b/core/modules/widgets/action-sendmessage.js index fa788240a..1431d3156 100644 --- a/core/modules/widgets/action-sendmessage.js +++ b/core/modules/widgets/action-sendmessage.js @@ -55,25 +55,19 @@ SendMessageWidget.prototype.refresh = function(changedTiddlers) { Invoke the action associated with this widget */ SendMessageWidget.prototype.invokeAction = function(triggeringWidget,event) { - // Get the parameter + // Get the string parameter var param = this.actionParam; - // If the parameter is missing then we'll assemble the attributes as a hashmap - if(!param) { - param = Object.create(null); - var count = 0; - $tw.utils.each(this.attributes,function(attribute,name) { - if(name.charAt(0) !== "$") { - param[name] = attribute; - count++; - } - }); - // Revert to an empty parameter if no values were found - if(!count) { - param = undefined; + // Assemble the attributes as a hashmap + var paramObject = Object.create(null); + var count = 0; + $tw.utils.each(this.attributes,function(attribute,name) { + if(name.charAt(0) !== "$") { + paramObject[name] = attribute; + count++; } - } + }); // Dispatch the message - this.dispatchEvent({type: this.actionMessage, param: param, tiddlerTitle: this.getVariable("currentTiddler")}); + this.dispatchEvent({type: this.actionMessage, param: param, paramObject: paramObject, tiddlerTitle: this.getVariable("currentTiddler")}); return true; // Action was invoked }; diff --git a/editions/prerelease/tiddlers/ActionSendMessageWidget.tid b/editions/prerelease/tiddlers/ActionSendMessageWidget.tid new file mode 100644 index 000000000..1e88732a2 --- /dev/null +++ b/editions/prerelease/tiddlers/ActionSendMessageWidget.tid @@ -0,0 +1,31 @@ +caption: action-sendmessage +created: 20141008134309742 +modified: 20141107132122081 +tags: Widgets ActionWidgets +title: ActionSendMessageWidget +type: text/vnd.tiddlywiki + +! Introduction + +The ''action-sendmessage'' widget is an [[action widget|ActionWidgets]] that sends a [[message|WidgetMessages]] back up the widget tree. ActionWidgets are used within triggering widgets such as the ButtonWidget. + +! Content and Attributes + +The ''action-sendmessage'' widget is invisible. Any content within it is ignored. + +|!Attribute |!Description | +|$message |The message to send (eg, [[WidgetMessage: tm-new-tiddler]]) | +|$param |Optional parameter string whose meaning is dependent on the message being sent | +|//{any attributes not starting with $}// |Multiple additional named parameters that are attached to the message | + +! Examples + +Here is an example of button that displays both a notification and a wizard, and creates a new tiddler with tags and text: + +<$macrocall $name='wikitext-example-without-html' +src='<$button> +<$action-sendmessage $message="tm-modal" $param="SampleWizard"/> +<$action-sendmessage $message="tm-notify" $param="SampleNotification"/> +<$action-sendmessage $message="tm-new-tiddler" title="This is newly created tiddler" tags="OneTag [[Another Tag]]" text=<>/> +Click me! +'/>