Hi Arlen

There's a much easier way to accomplish what you're trying to do. Using
variables to store state is a red-herring; you should use tiddlers for
state storage. Variables are attached to the render tree nodes; they are
provided as a way of providing values that can vary at different points in
the tree.

One further oddity is the way that you are combing both displayable
wikitext and a stylesheet in the same tiddler. That isn't recommended; the
plain text output of the wikitext will be parsed as CSS which is probably
not what you want.

Here's a simpler alternative:

<$reveal state="$:/state/myTriState" type="match" text="one"
default="one"><$button set="$:/state/myTriState" setTo="two">One, click for
Two</$button></$reveal>
<$reveal state="$:/state/myTriState" type="match" text="two"><$button
set="$:/state/myTriState" setTo="three">Two, click for
Three</$button></$reveal>
<$reveal state="$:/state/myTriState" type="match" text="three"><$button
set="$:/state/myTriState" setTo="one">Three, click for
One</$button></$reveal>

Best wishes

Jeremy



On Fri, Feb 14, 2014 at 2:06 PM, Arlen Beiler <[email protected]> wrote:

> 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.
>



-- 
Jeremy Ruston
mailto:[email protected]

-- 
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