Hi 

I gave it a try like this

<$mytest>
<$button message="myTest-message">
x
</$button>
</$mytest>

you need to delete 'tiddler' here



    var newTiddler = new $tw.Tiddler(this.wiki.getCreationFields(),tiddler,{

all the best
BJ

On Monday, October 16, 2017 at 4:40:24 AM UTC+2, [email protected] wrote:
>
> I am trying to create a simple testing widget that listens for a message, 
> and creates a new tiddler.
>
> I've had no louck with this, and as best i can tell, my widgets event 
> handler is never triggering.
>
> Any assistance in pointing out what i am doing wrong would be greatly 
> appreciated.
>
> Thanks,
>   -- Kenn
>
> /*\
>
> title: myTestWidget
> type: application/javascript
> module-type: widget
>
> myTest widget
>
> \*/
> (function(){
>
> /*jslint node: true, browser: true */
> /*global $tw: false */
> "use strict";
>
> var Widget = require("$:/core/modules/widgets/widget.js").widget;
>
> var myTestWidget = function(parseTreeNode,options) {
>     this.initialise(parseTreeNode,options);
>     this.addEventListeners([
>         {type: "myTest-message", handler: "handlemyTestEvent"}
>     ]);
> };
>
> /*
> Inherit from the base widget class
> */
> myTestWidget.prototype = new Widget();
>
> /*
> Render this widget into the DOM
> */
> myTestWidget.prototype.render = function(parent,nextSibling) {
>     this.parentDomNode = parent;
>     this.computeAttributes();
>     this.execute();
>     this.renderChildren(parent,nextSibling);
> };
>
> /*
> Compute the internal state of the widget
> */
> myTestWidget.prototype.execute = function() {
>     // Get attributes
>
>     // Construct the child widgets
>     this.makeChildWidgets();
> };
>
> /*
> Selectively refreshes the widget if needed. Returns true if the widget or any 
> of its children needed re-rendering
> */
> myTestWidget.prototype.refresh = function(changedTiddlers) {
>     var changedAttributes = this.computeAttributes();
>     if(changedAttributes.story || changedAttributes.history) {
>         this.refreshSelf();
>         return true;
>     } else {
>         return this.refreshChildren(changedTiddlers);
>     }
> };
>
>
> myTestWidget.prototype.handlemyTestEvent = function(event){
>     var loginTiddler = this.wiki.getTiddler("$:/state/login");
>
>     var newTiddler = new $tw.Tiddler(this.wiki.getCreationFields(),tiddler,{
>           title: "DebugTiddler",
>           "draft.title": undefined,
>           "draft.of": undefined
>     },this.wiki.getModificationFields());
>     this.wiki.addTiddler(newTiddler);
> };
>
> exports.mytest = myTestWidget;
>
> })();
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWikiDev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/tiddlywikidev.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywikidev/abfa7bf1-3111-4196-853c-b86f00b8d4db%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to