Thank you, Eric!

That worked great, and I just updated it. 
https://giffmex.org/experiments/roamwiki.experiment.html

Dave

On Wednesday, January 29, 2020 at 6:54:04 PM UTC-6, Eric Shulman wrote:
>
> On Wednesday, January 29, 2020 at 4:02:41 PM UTC-8, David Gifford wrote:
>>
>> The default new-journal-here button, which I cloned, is not amenable to 
>> changes (in this case adding what needs to go in the text field) with this 
>> happening. The offending tiddler is 
>> $:/.giffmex/ViewToolbar/new-note-here-datetime.  
>> <https://giffmex.org/experiments/roamwiki.experiment.html#%24%3A%2F.giffmex%2FViewToolbar%2Fnew-note-here-datetime>
>>
>
> If a button's actions are defined "inline" within the button definition 
> (as you have done), then they are parsed when the button is rendered.
>
> This results in an unchanging timestamp for the journal title, which 
> causes the old journal to be overwritten each time the button is clicked.
>
> However...
>
> If the button's actions are defined in a separate macro that is invoked 
> via the actions=<<macroname>> syntax,
> then parsing of the action code is deferred until the button is actually 
> pressed, and is **re-calculated each time the button is pressed**
>
> This code works as you intend:
> \whitespace trim
>
> \define journalButtonActions()
> <$action-sendmessage $message="tm-new-tiddler" title=<<now 
> """$(journalTitleTemplate)$""">> text="""[[$(tid)$]]""" />
> \end
>
> \define journalButtonTags()
> [[$(currentTiddlerTag)$]] $(journalTags)$
> \end
>
> \define journalButton()
> <$button tooltip={{$:/language/Buttons/NewJournalHere/Hint}}
>    aria-label={{$:/language/Buttons/NewJournalHere/Caption}}
>    class=<<tv-config-toolbar-class>>
>    actions=<<journalButtonActions>>>
>    <$list filter="[<tv-config-toolbar-icons>match[yes]]">
>       {{$:/core/images/timestamp-on}}
>    </$list>
>    <$list filter="[<tv-config-toolbar-text>match[yes]]">
>       <span class="tc-btn-text">
>          <$text text={{$:/language/Buttons/NewJournalHere/Caption}}/>
>       </span>
>    </$list>
> </$button>
> \end
>
> <$set name="journalTitleTemplate" value={{$:/config/NewJournal/Title}}>
> <$set name="tid" value=<<currentTiddler>>>
> <<journalButton>>
> </$set>
> </$set>
>
>
>
> enjoy,
> -e
>
>>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/d29fc91d-7a16-4713-a773-3b33b40132f2%40googlegroups.com.

Reply via email to