On Tuesday, June 9, 2020 at 5:20:10 AM UTC-7, Lars Solberg wrote:
>
> I am trying to create a shortcut to create a bunch of different 
> journal-types. They will have different template-text, titles and so on.
> Mostly, the title will contain a suffix coming from an <$edit-text, but 
> they also a macro <<now>>.
> Below is what I got so far, it works, but the text-box looses focus after 
> a keypress. I think I am hitting the issue @ 
> https://github.com/Jermolene/TiddlyWiki5/issues/341 (from 2014), but I'm 
> not sure.
> Anyone got any idea how to solve this? Or maybe there is a plugin around 
> that does what I want instead?
>

Every keystroke in the $edit-text widget changes the value of 
$:/state/new-journal-log-title,
which triggers and automatic refresh of everything inside the <$set 
name="titleSuffix" value={{$:/state/new-journal-log-title}}>
This includes the $edit-text widget itself, which causes the input control 
to lose focus after each keystroke.

To fix this, simply move the $edit-text widget outside of the <$set>, like 
this:
 

> \define journalLogButton()
> <$button>
> <$action-sendmessage
>   $message="tm-new-tiddler"
>   title=<<now "YYYY-0MM-0DD $(titleSuffix)$ ">>
>   tags="Journal"
>   journal-type="log"
>   year=<<now "YYYY">>
>   month=<<now "0MM">>
>   day=<<now "0DD">>
> />
> New log
> </$button>
> \end
>
> <$edit-text tiddler="$:/state/new-journal-log-title" tag="input" 
> default=""/>
> <$set name="titleSuffix" value={{$:/state/new-journal-log-title}}>
> <<journalLogButton>>
> </$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 tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/af9442f0-a23b-4e55-bcee-0450b623a5a2o%40googlegroups.com.

Reply via email to