How prevent edit-text from losing focus?

296 views
Skip to first unread message

Mat

unread,
Mar 4, 2021, 8:54:24 AM3/4/21
to TiddlyWiki
It is a known issue that an EditTextWidget loses focus if it edits the current tiddler (see doc tiddler, under "Notes") I was expecting the TiddlerWidget to be able to prevent this by changing the context for the editor,  but it doesn't work. Why doesn't this work and what should I do if I don't want to involve other (real) tiddlers?

<$vars curr=<<currentTiddler>>>
   <$tiddler tiddler=dummy>
      <$edit-text tiddler=<<curr>> field=f/>
   </$tiddler>
</$vars>

Thanks!

<:-) 

Mohammad Rahmani

unread,
Mar 4, 2021, 9:04:59 AM3/4/21
to tiddl...@googlegroups.com
Mat, I think by every input in the text box, TW refresh the tiddler! 
So, why no to use a temp tiddler then?



Best wishes
Mohammad


--
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+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/df1785e9-a506-4099-8090-f3d59727a1e2n%40googlegroups.com.

Mat

unread,
Mar 4, 2021, 11:52:26 AM3/4/21
to TiddlyWiki
Thanx Mohammad.
It is in a template for modifying the <<currentWidget>>, so if I put it in a separate tiddler I don't know what to type here:

<$edit-text tiddler=??????? field=f/>

To be more specific:

All tiddlers that are tagged Image, have a htm <img> element to show an image. The <img> tag has a width attribute. But this width of the image should be possible to control - so I want a template to show a an EditTextWidget above the image. This widget should show the width field of the current tiddler.

...but this doesn't seem to work; it loses focus as soon as I type a letter into the edittextwidget.

<:-)
 

Mohammad Rahmani

unread,
Mar 4, 2021, 12:13:10 PM3/4/21
to tiddl...@googlegroups.com


On Thu, Mar 4, 2021 at 8:22 PM Mat <matia...@gmail.com> wrote:
Thanx Mohammad.

Hi Mat

 
It is in a template for modifying the <<currentWidget>>, so if I put it in a separate tiddler I don't know what to type here:

<$edit-text tiddler=??????? field=f/>

Use a template contains below line with all other coding you need

\define tmpTid() xx$:/temp/$(currentTiddler)$

<$edit-text tiddler=<<tmpTid>> field=f/>

I think it should work. 

 

Mohammad Rahmani

unread,
Mar 4, 2021, 12:38:12 PM3/4/21
to tiddl...@googlegroups.com
Mat
Could you give a try on https://tiddlywiki.com/
A sample template and example is attached!


Best wishes
Mohammad


On Thu, Mar 4, 2021 at 8:22 PM Mat <matia...@gmail.com> wrote:
test-image-set-width.json

Mat

unread,
Mar 4, 2021, 12:57:33 PM3/4/21
to TiddlyWiki
That is *very* kind of you Mohammad.
I am just about to go out so will look closer after but it seems the modified field is not in Pelican, where I wish it should be. Will investigate later.
Thanks!!!
<:-)

Mat

unread,
Mar 4, 2021, 4:16:36 PM3/4/21
to TiddlyWiki
So this presents the problem:

https://edittextcurrent.tiddlyhost.com/

I'd appreciate it if anyone can take a look and tell me what I'm doing wrong. And I'm curious why the EditTextWidget is not tricked to believe it is elsewhere by the tiddler=dummy ...I thought that was kind of the point with the TiddlerWidget.

<:-)

BJ

unread,
Mar 4, 2021, 5:17:08 PM3/4/21
to TiddlyWiki
Hi Mat,
changes to a tiddler trigger the refresh mechanism - and if the tiddler is displayed then it will be re-rendered, which destroy the underlying text box in you case and then recreates it - and thus loses focus. If you add a field called 'throttle.refresh' to your tiddler it will make things a bit better, but there is no solution (outside of modify the core).

all the best BJ

Mat

unread,
Mar 4, 2021, 5:34:17 PM3/4/21
to TiddlyWiki
BJ, big thanks. 'throttle.refresh' does improve things. In another version I'm using a RangeWidget to set the width and your trick works even better for that.

As for "modify the core", do you think there is a real reasonable solution for this or is it one of those known issues that are stuck? Shoud I raise an Issue?

Again, thank you!

<:-)

BJ

unread,
Mar 4, 2021, 6:23:13 PM3/4/21
to TiddlyWiki
many many moons ago there was a issue for this


but the current method was chossen instead.

Another choice is to us a 'submit' type button:


\define img(url, width) <img src="$url$" height="50px" width="$width$"/>

<$list filter="""[tag[Image]]""">

   <$vars curr=<<currentTiddler>>>
      <$tiddler tiddler=dummy>
         width: <$edit-text tiddler=temptid field=text tag="input"/>
      </$tiddler>
   </$vars>
</$list>
<$button>
<$action-setfield  width={{temptid}}/>
set width
</$button>
<$macrocall $name=img url={{!!url}} width={{!!width}}/>

Mat

unread,
Mar 4, 2021, 6:54:02 PM3/4/21
to TiddlyWiki
BJ wrote:
many many moons ago there was a issue for this


but the current method was chossen instead.

So I take it the problem I hit here wasn't really solved then.

Another choice is to us a 'submit' type button:

Yeah... not really happy with that for the application I have in mind, but thanks.

<:-)

Flibbles

unread,
Jun 30, 2023, 10:03:36 AM6/30/23
to TiddlyWiki
For real though,

What is the workaround for this? Why does it happen? It seems like it should be fixable, because it doesn't happen if you're editing the "text" field, or if you're editing an index, or if "currentTiddler" never gets set. This seems super specific, but it's also a use case that literally anyone using $edit-text might use.

I'm trying to edit a field which has no bearing on the visible rendering. Is there a known workaround?

PMario

unread,
Jul 3, 2023, 3:26:19 PM7/3/23
to TiddlyWiki
The issue as described in the OP does not exist anymore.
It has been resolved I think with 5.2.0 ... or so

@Flibbles. Can you be more specific. May be create a new issue at GH?

-m

Reply all
Reply to author
Forward
0 new messages