Make range widget update according to given field

73 views
Skip to first unread message

David Allen

unread,
Oct 10, 2019, 8:10:40 PM10/10/19
to TiddlyWiki
Right now I have a range widget that controls a scroll_index field.  It increments by 1.  I also have two buttons that increment and decrement the same scroll_index by 5.  Problem is, when I use the buttons, the range widget does not update to reflect the modified scroll_index value, and I'd like it to do so.  Is there a way to force the range widget to reflect the scroll_index value?

David Allen

unread,
Oct 15, 2019, 2:42:29 PM10/15/19
to TiddlyWiki
So I came up with an inelegant solution that solves the problem.

To clarify the situation I had, I had a list of tiddlers that would only show five at a time, and would scroll using a range widget and a left/right button combination.  The range widget scrolls by 1, the left/right buttons scroll by five.  The issue I had was the list and buttons were working correctly, but the range widget was not updating according to the input of the buttons.

The first solution I had was to move the field being modified to another tiddler, which I called Scratch_Pad.  This did not work, but it was convenient for me for later on.

Second solution I had was to change the default value of the range widget to equal Scratch_Pad!!scroll_index, which is the same value the widget and the buttons modified.  It worked, but the slider was very difficult to use as it would de-select itself every time I moved the slider, requiring me to re-click the slider and move it one-by-one every time I wanted to change the value.

The solution that finally worked is a bit wonky.  I read in another thread that modifying a draft of a tiddler works smoothly for the range widget.  The problem I had was having the default value of the range widget be the same field as the value the range widget was trying to modify.  Here's what I did instead:

Set the tiddler the range widget modifies to be Draft of 'Scratch_Pad', keeping the field as scroll_index
Set the default it pulls from to be Scratch_Pad!!scroll_index, NOT the draft
Set the value the buttons base their calculations on to Draft of 'Scratch_Pad'!!scroll_index.  This makes sure the buttons will move the value last updated by the range widget.
When the buttons calculate the new values, make sure they update the scroll_index fields in both the Scratch_Pad AND Draft of 'Scratch_Pad' tiddlers to update the range widget's position and make sure the value it next calculates is accurate
Base the horizontal list's position on the Draft of 'Scratch_Pad' value.

Jeremy Ruston

unread,
Oct 15, 2019, 4:36:32 PM10/15/19
to tiddl...@googlegroups.com
Hi David

Please could you post the code you referred to in your original post? I have a feeling that the draft thing might be a red herring, and that this may be about avoiding refresh cycles that destroy and recreate the range widget while it is being used (which is a version of a classic TW5 gotcha: that one cannot use an edit widget to edit a field of the tiddler in which the edit widget appears).

Best wishes

Jeremy

--
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/840e4f1b-55e2-4151-8eb5-376bb9199c0d%40googlegroups.com.

David Allen

unread,
Nov 11, 2019, 4:51:16 PM11/11/19
to TiddlyWiki
Sorry it's taken me a while to respond. I've posted an unrelated question regarding the same code here: https://groups.google.com/forum/?hl=en&fromgroups#!topic/tiddlywiki/RSecD3M6Vio, so the code that solved this should be visible there.
Jeremy

To unsubscribe from this group and stop receiving emails from it, send an email to tiddl...@googlegroups.com.

Eric Shulman

unread,
Nov 11, 2019, 9:18:23 PM11/11/19
to TiddlyWiki
On Thursday, October 10, 2019 at 5:10:40 PM UTC-7, David Allen wrote:
Right now I have a range widget that controls a scroll_index field.  It increments by 1.  I also have two buttons that increment and decrement the same scroll_index by 5.  Problem is, when I use the buttons, the range widget does not update to reflect the modified scroll_index value, and I'd like it to do so.  Is there a way to force the range widget to reflect the scroll_index value?

I ran into the same issue with using a button to modify the underlying tiddler value shown in a range widget, and reported it directly to Jeremy during a one-to-one Skype chat.

It turns out that there was a bug in the $range widget refresh handler, which Jeremy has fixed in TW5.1.22 (pre-release).


enjoy,
-e
Reply all
Reply to author
Forward
0 new messages