Is delay an attribute of the action-sendmessage-widget?

I found this snippet in a thread

I could not find this in the docs and have been using Jeds delay-action-plugin so far.
It would be very practical if this was a core feature and if it was documented.

1 Like

The delay is not supported by the core and unlikely to to be a core feature, see Add an optional delay to the tm-focus-selector action by BurningTreeC ¡ Pull Request #6606 ¡ Jermolene/TiddlyWiki5 ¡ GitHub

1 Like

Hi @JanJo ,

In my multi-column Layout I’ve added this delay to the tm-focus-selector message so that I can focus an input that’s not yet animated into view when a button is clicked.
This is not a tiddlywiki core feature.

Best wishes,
Simon

2 Likes

Aaah thanks!
There are some widgets where it would be great to have the possibility to delay the actions.
action-sendmessage,
action-setfield,
…
Perhaps it would be an idea simply to have an action-delay-widget that could put between two widgets?

see:
https://tiddlytools.com/timer.html#TiddlyTools%2FTime%2Faction-timeout.js

  • To invoke actions one time, use <$action-timeout delay=nnnn actions=... />.
  • To invoke actions repeatedly, use <$action-timeout interval=nnnn actions=... />.
  • delay and interval are specified in milliseconds (a non-zero numeric value is required).
  • actions can be specified using quoted text or a macro reference.
  • There are three different methods you can use to start interrupt-driven timer processing:
    1. Enclose the <$action-timeout> widget within a <$button> widget. Interrupt-driven timeout processing will start when you click on the button.
    2. or, place the <$action-timeout> widget in a tiddler tagged with $:/tags/StartupAction/Browser. Interrupt-driven timeout processing will automatically start when you save-and-reload your TiddlyWiki file.
    3. or, place the <$action-timeout> widget in any tiddler and add an autostart="yes" param to the widget. Interrupt-driven timeout processing will automatically start each time the tiddler content is rendered.
  • If you add tid="tiddlername" and field="fieldname" params (defaults to text), a unique system-generated timeout/interval ID value will be stored in the specified tiddler field. Then, to cancel an active timeout/interval, you can use <$action-timeout clear={{tiddlername!!fieldname}}/>.

For example:

To click a button and delay 5 seconds before setting a tiddler field, you could write:

\define dosomething() <$action-setfield ... />
<$button> CLICK ME <$action-timeout delay=5000 actions=<<dosomething>>/></$button>

and if you want to have a repeating action once per second that starts immediately upon rendering and automatically stops after 30 seconds, you could write:

\define tick()   <$action-setfield $tiddler="ticker" text=<<now "0hh:0mm:0ss">>/>
\define stop(id) <$action-timeout clear={{$id$}}/><$action-deletetiddler $tiddler="$id$"/>

<$action-timeout interval=1000 autostart=yes tid=timerID actions=<<tick>>/>
<$action-timeout delay=30000 autostart=yes actions=<<stop timerID>>/>

{{ticker}} <$list filter="[[timerID]is[tiddler]]" emptyMessage="STOPPED">RUNNING</$list>

enjoy,
-e

3 Likes

Thank you Eric!
This is so neat and useful that it should be part of the core!

Is the delay feature integrated into 5.3 now? I found another thread on a new “oncompletition” mode

I am confident it was not because its not documented. However Erics solution should be fine.

Yeah, TiddlyTools’ delay works great - but if the TIddler is forgotten, its lack produces an ugly widget not defined.

To suppress display of unwanted “Undefined widget ‘action-timeout’” messages when TiddlyTools/Time/action-timeout.js is missing, you can simply wrap the widget within @@display:none;...@@. Thus:

@@display:none;<$action-timeout delay="1000" actions=<<myTimeoutActions>>/>@@
1 Like

Thanks for this hack! But your feature is so important I would like to see it in the core.