How to reset tiddler fields when it opens

55 views
Skip to first unread message

vpl

unread,
May 17, 2021, 5:08:35 AM5/17/21
to TiddlyWiki
Hi

I try to invokea macro that reset tiddler fields when we open it. By opening I do not mean for editing, I mean the tiddler is invoked via a link for example

Why the below code is not working ??

\define macro_init()
Hello guy
<$action-setfield  $tiddler=<<currentTiddler>> $field="todel" $value="init_value"/>
<$action-setfield  profile_name=''/>
<$action-setfield  query_toggle=''/>
\end
<<macro_init>>

Any body having a solution ?

regards

PMario

unread,
May 17, 2021, 6:42:41 AM5/17/21
to TiddlyWiki
Hi vpl,

Action-widgets are only activated, if a "user-action" happens. So mainly by clicking a button, radio- and checkbox-widget, keyboard-shortcuts and so on.

You would need to modify the "edit-button". ... But why do you need this?


-mario

vpl

unread,
May 17, 2021, 7:17:46 AM5/17/21
to TiddlyWiki
Hi

Thanks a lot for your answer
In fact I have a tiddler containing different fields that I use in different macros
I've successfully added a "Reset" button that reset all my fields to the default value
What I'm looking for is a way to avoid this "manual" reset operation and trigger automatically the macro when the tiddler is invoked from the home tiddler for ex (via a link) or from the search button.

So I suspect that internally tiddlywiki has a mechanism to invoke macro at that time, but I cannot find it

Thanks again for your support

Regards

TW Tones

unread,
May 17, 2021, 8:38:30 PM5/17/21
to TiddlyWiki
vpl,

You need to delve into the link catcher widget. You can then add actions (ideally conditional) , perhaps designing it to happen with a particular modifier key (not ctrl) pressed at the same time as a click. You could try and intervein in the core process, but if you are happy to generate a list of tiddler links that have their own link catcher and matching additional actions it would be safer and easier.

Tones

PMario

unread,
May 18, 2021, 7:59:07 AM5/18/21
to TiddlyWiki
On Monday, May 17, 2021 at 11:08:35 AM UTC+2 vpl wrote:

I try to invokea macro that reset tiddler fields when we open it. By opening I do not mean for editing, I mean the tiddler is invoked via a link for example

hmmmm, You should have highlighted the _not_  ... I did only see/read for editing.

I do have a widget, which is called <$trigger actions=<<anyAction>> /> ... It is "triggered" whenever the widget is rendered or re-rendered. ...

So it has some potential to completely brick your wiki, if done wrong. ...

The risk to loose data is especially high, while developing the action-code and the "preview pane" is active. Because <$action-setfield .. with wrong parameters can completely ruin tiddler content. ... So be warned .... BACKUP - BACKUP  - BACKUP


There is no documentation yet. So you have to open the tiddlers in the link, to see what's going on.

I would implement the development code like this:

title: myFooter
tags: $:/tags/ViewTemplate

<$list filter="[all[current]tag[test]]">
<$trigger actions= ...../>
</$list>

So you can use the tag: test to switch the action on / off.

have fun!
mario
PS: Be sure to BACKUP - BACKUP  - BACKUP
PPS: The preview-pane will trigger the actions!!!

Reply all
Reply to author
Forward
0 new messages