Hi Stobot! Have you found a solution? 

*This works for me...*
\define newtiddlername() $(mytitle)$ $(now)$
\define addnewtiddler() *<$vars 
mytitle={{$:/temp/mytitle}}>*<$action-createtiddler 
$basetitle=<<newtiddlername>>/>*</$vars>*

<$keyboard key="enter" actions=<<addnewtiddler>>>
<$edit-text tiddler="$:/temp/mytitle" tag="input" default=""/>
<$button actions=<<addnewtiddler>>>
Add
</$button>
</$keyboard>

That is, moving <$vars> widget to nearest possible place where it will be 
used...


*With these previous code....*
<$keyboard key="enter" actions=<<addnewtiddler>>>
<$edit-text tiddler="$:/temp/mytitle" tag="input" default=""/>
<$vars mytitle={{$:/temp/mytitle}}>
<$button actions=<<addnewtiddler>>>
Add
</$button>
</$vars>
</$keyboard>

The button will use the <<mytitle>> that is already declared... While the 
keyboard is trying to use the same variable -- however, it's not declared 
yet "above" it!

*But*! moving <$vars> "above" <$keyboard> means that with every key press, 
<$vars> has to recompute (don't know the exact terms / mechanism here), 
refreshing its contents, taking away the focus from all inside it, 
including <$text-edit>... 

So, moving <$vars> inside <<addnewtiddler>> means that as long as 
<<addnewtiddler>> isn't being ran, <<mytitle>> won't recompute, won't 
refresh that part of the DOM 

Hopefully someone can explain all these better for me lol ! I am so bad at 
this

-jd


On Tuesday, July 28, 2020 at 2:59:53 AM UTC+9, Stobot wrote:
>
> I'm running into what seems to be a scope issue and not sure how to work 
> around it. I'm hoping that some experts here might see what I'm doing 
> wrong. 
>
> I have an edit-text widget for the user to enter a new title name, and 
> then I need to append a date to the end of it and create a new tiddler for 
> it. I can have that work with the button no problem, but can't figure out 
> how to add they keyboard shortcut properly. 
>
> This works from a button standpoint:
>
> \define newtiddlername() $(mytitle)$ $(now)$
> \define addnewtiddler() <$action-createtiddler 
> $basetitle=<<newtiddlername>>/>
>
> <$edit-text tiddler="$:/temp/mytitle" tag="input" default=""/>
> <$vars mytitle={{$:/temp/mytitle}}>
> <$button actions=<<addnewtiddler>>>
> Add
> </$button>
> </$vars>
>
> but this doesn't work
>
> \define newtiddlername() $(mytitle)$ $(now)$
> \define addnewtiddler() <$action-createtiddler 
> $basetitle=<<newtiddlername>>/>
>
> <$keyboard key="enter" actions=<<addnewtiddler>>>
> <$edit-text tiddler="$:/temp/mytitle" tag="input" default=""/>
> <$vars mytitle={{$:/temp/mytitle}}>
> <$button actions=<<addnewtiddler>>>
> Add
> </$button>
> </$vars>
> </$keyboard>
>
> I tried moving the vars outside of the keyboard, but then each character 
> typed makes the input box lose focus... 
>
> Ideas?
>

-- 
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/0487e744-e2fd-4cd3-9a99-9fab6a573d07o%40googlegroups.com.

Reply via email to