In widgets/set.js I added an event listener and a handler. I copied the
idea from the fieldmangler widget.

var SetWidget = function(parseTreeNode,options) {
this.initialise(parseTreeNode,options);
 this.addEventListeners([
{type: "tw-set-var", handler: "handleSetVarEvent"},
]);
};
SetWidget.prototype.handleSetVarEvent = function(event) {
console.log([event,this]);
var params = JSON.parse(event.param);
    if(params != undefined) {
    if(this.setName == params[0])
this.setValue = params[1];
    } else {
    if(this.setName == "currentTiddler")
        this.setValue = event.param;
    }
this.setVariable(this.setName,this.setValue);
    this.refresh(event.tiddlerTitle)
};

And in a tiddler, I have this content. The variable seems to get updated
according to the console.log output, but how do I make the tiddler refresh
itself so that everything gets updated? Seems like in TW2 I would have used
onclick or something like that. I don't know, I never tried a three state
button on there. Thanks everyone.

The tiddler $:/Arlen/sidebar3way defines which button is visible and sets
the other things as well. The tiddler below has a stylesheet tag.

\define getStyle()
{{$:/Arlen/sidebar3way##$(state)$}}
\end
<$set name="state" value="normal">
@@float:right;
<span title="Toggle width/sidebar">
<$button message="tw-set-var" param='["state","wide"]' class="btn-invisible
sidebar-toggle-1">{{$:/_images/right-arrow-button}}</$button>
<$button message="tw-set-var" param='["state","full"]' class="btn-invisible
sidebar-toggle-2">{{$:/_images/right-arrow-button}}</$button>
<$button message="tw-set-var" param='["state","normal","refresh"]'
class="btn-invisible
sidebar-toggle-3">{{$:/_images/left-arrow-button}}</$button>
</span>
@@
@@display:none;
.sidebar-toggle-1,
.sidebar-toggle-2,
.sidebar-toggle-3 { display:none; }
<<getStyle>>
@@
</$set>

-- 
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 http://groups.google.com/group/tiddlywikidev.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to