TW5 button popup to set a field/index?

62 views
Skip to first unread message

myst...@gmail.com

unread,
Jul 14, 2017, 10:10:19 PM7/14/17
to TiddlyWiki
I am attempting to create a button that, when clicked, pops up a <$list> of tiddlers w/ a specified set of tags.
on clicking a list item, it sets a field/index in the specified tiddler.

This is a for a spell sheet template for a dnd campaign notebook i am making.

I was attemping to adapt from Tobias' popup macros, but i am butchering it terribly.

Can someone clue me in on what i'm doing wrong?

\define choose_spell(field:nofield tags:"")
<$set name="state" value=<<qualify """$:/state/pop-$field$""">>>
<$button popup=<<state>> class="pop-btn" selectedClass="pop-btn-selected">$field$</$button><$reveal type="popup" state=<<state>> class="tc-popup pop-popup" set="$(title)$">
<div class="tc-block-dropdown">
<$linkcatcher  setTo="$field$">
<div class="tc-dropdown-item">
<$list filter="[tag[Spell]$(tags)$]">
<$link to=<<state>> >{{##title}}</$link>
</$list>
</div>
</$linkcatcher>
</div>
</$reveal>
</$set>
\end

<span>

  {{##myfield}} <<choose_spell myfield "Spell Level/0 [Class Paladin]">>

</span>

Mark S.

unread,
Jul 14, 2017, 11:50:21 PM7/14/17
to TiddlyWiki
Maybe instead of whatever the linkcatcher is suppose to do (sure would be nice if someone completed it's documentation with an example or two), maybe generate a list of pop-up buttons. Like:

\define choose_spell(field:nofield tags:"")
<$button popup="$:/listpop">Pop up list</$button>

<$reveal type="popup" state="$:/
listpop">
<$list filter="
[tag[$tags$]]">
<div class="
tc-dropdown-item">
<$button set="
!!$field$" setTo="YES"><$view field="title"/></$button>
</div>
</$list>

</$reveal>

\end

<<choose_spell "
stuff" "HelloThere">>


In your example, I couldn't figure out what you wanted set to what. So these buttons just put a text value "YES" in the "stuff" field of the tiddler that is clicked on. If you want the generated buttons to look like links, I think you just add some classes to them.

In your example you were using {{##myfield}} at the bottom which I didn't understand because ## is text reference to a data dictionary entry. You can't be referring to a data dictionary (AFAIK) that is the same tiddler that you are currently in. So ... are you trying to pull from a data dictionary somewhere?

Good luck!
Mark
Reply all
Reply to author
Forward
0 new messages