two ways to do things in a button

61 views
Skip to first unread message

Joe Armstrong

unread,
Jan 31, 2019, 10:59:51 AM1/31/19
to TiddlyWiki
I wrote this code to do two things when you click on a button - it adds a tag and closes the sidebar

<$fieldmangler>
<$button>
<$action-setfield $tiddler="$:/state/sidebar" 
text ="no" /> 
<$action-sendmessage $message="tm-add-tag" $param="wow"/>
   Add  tag `wow` and collapse the sidebar
</$button>
</$fieldmangler>

It works fine - but when I wrote it felt strange.

I looked for but could not find an action-sendmessage that sets the field of a tiddler

I'd kind of expected to find
something like

<$action-sendmessage $message="tm-set-field" $tiddler="$:/state/sidebar" text="no" />

Which would make the body the button easier
to understand.

My mental model of a button is something
that when you press it sends messages to different parts of the system, causing things to happen. 

Can't everything be done with messages?

Cheers
/Joe

Jeremy Ruston

unread,
Jan 31, 2019, 11:29:03 AM1/31/19
to tiddl...@googlegroups.com
Hi Joe

There’s an <$action-setfield> widget which allows values to be assigned to fields:


There’s also an <$action-listops> widget that allows a field value to be modified (e.g. adding or removing a specific entry from a list):


Best wishes

Jeremy


--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/4084692d-cf3f-4f77-8ee4-093aebcafccf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages