Hello all!
I’m working on some UI elements and as part of the edition UI of a tiddler (of a Character). I have the following code in that Character tiddler:
<$let spellbookname={{{ [<currentTiddler>get[draft.title]addsuffix[/spellbook]] }}}> <!-- using draft.title instead of title because the button appears only when editing the Character tiddler, thus renaming it with 'draft of' -->
<$macrocall $name="create-new-spellbook-button-char" title=<<spellbookname>> navigate="no"/></$let>
The create-new-spellbook-button-char
procedure is supposed to create a button that if pressed will create a new tiddler titled <<spellbookname>>
and NOT navigate to it, which works well. However, I also want this button to give the value <<spellbookname>>
to the spellbook
field that is on the Character tiddler the button is clicked from.
Here are the rest of the macros I used for that button:
\function spellbook.tags() GURPS Spellbook +[join[ ]format:titlelist[]]
\procedure spellbook.button.actions.char()
<$macrocall $name='create-new-spellbook' title=<<title>> navigate='no'/>
\end
\procedure create-new-spellbook(title, navigate:yes)
<$action-createtiddler $basetitle=<<title>> tags=<<spellbook.tags>> type="application/x-tiddler-dictionary" icon="$:/GURPS/icons/spellbook">
<% if [<navigate>match[yes]] %><$action-navigate $to=<<createTiddler-title>>/><% endif %>
</$action-createtiddler>
\end
\procedure create-new-spellbook-button-char(title)
<$button actions=<<spellbook.button.actions.char>>>
<$action-setfield $tiddler=<<currentTiddler>> $field='spellbook' $value=<<title>>/>
{{$:/GURPS/icons/spellbook}} New spellbook
</$button>
\end
I feel like it’s all wobbly code, but since the main part (creating the spellbook dictionary tiddler with the correct name and tag) works well, I’m left wondering why the button’s immediate child widget <$action-setfield>
doesn’t change the field as intended?
You can take a look directly at the TW here