Saved title for action-createtiddler only available AFTER run ?

159 views
Skip to first unread message

Mark S.

unread,
Dec 17, 2020, 7:07:38 PM12/17/20
to TiddlyWiki
In prerelease 5.23, if I run something like:

<$action-createtiddler $basetitle="Excerpt" $savetitle="$:/savedtitle" tags="Excerpt" text=<<actionText>> />

The title saved in $:/savetitle doesn't become available until AFTER the routine it is in finishes. This means it is too late to be used by other widgets inside of the same routine/macro.

I feel like this problem was encountered before, and there was some sort of fix for it. Does anyone remember what that might be? Or if it's something that's a known problem?

Thanks!

Eric Shulman

unread,
Dec 17, 2020, 8:22:40 PM12/17/20
to TiddlyWiki
A $button can actually invoke two sets of action widgets:

First, when clicked, any action widgets that occur in the body of the button are invoked.
Then, if the $button has an actions="..." parameter, those actions are invoked afterwards.

Thus, you can do something like:

<$button actions="""<$action-setfield $title={{$:/savedtitle}} ... />""">
   click me
   <$action-createtiddler $basetitle="..." $savetitle="$:/savedtitle" etc... />
</$button>

note that, for readability, you could also define separate macros for each set of actions, and then invoke them like this:

\define buttonactions_1() <$action-createtiddler $basetitle="..." $savetitle="$:/savedtitle" etc... />
\define buttonactions_2() <$action-setfield $title={{$:/savedtitle}} ... />

<$button actions=<<buttonactions_2>>> click me <<buttonactions_1>> </$button>

-e

Mark S.

unread,
Dec 17, 2020, 9:02:55 PM12/17/20
to TiddlyWiki
In this case there is no button -- it's being triggered by a drop event onto a droppable widget.

Thanks!

PMario

unread,
Dec 17, 2020, 9:12:12 PM12/17/20
to TiddlyWiki
Hi Mark,
You may be able to use the <$linkcatcher widget to trigger a new action. ...

So your first action define the $savetitle  ... and a second actions sends a tm-link-to, which is catched by the linkcatcher actions. It should / may be available.

With 5.1.23 there is a new https://tiddlywiki.com/prerelease/#EventCatcherWidget, which I didn't test yet.

-m


PMario

unread,
Dec 17, 2020, 9:13:34 PM12/17/20
to TiddlyWiki
On Friday, December 18, 2020 at 3:12:12 AM UTC+1 PMario wrote:

So your first action define the $savetitle  ... and a second actions sends a tm-link-to, which is catched by the linkcatcher actions. It should / may be available.

I meant tm-navigate ...

-m

Mark S.

unread,
Dec 17, 2020, 9:27:52 PM12/17/20
to TiddlyWiki
That's an interesting idea. But tm-link-to doesn't show up anywhere in the documentation, or a search in system or shadows. Are you sure it exists yet?

Thanks!

TW Tones

unread,
Dec 17, 2020, 10:33:30 PM12/17/20
to TiddlyWiki
<$action-createtiddler  allows you to created tiddlers "silently", you then use as Mario said  tm-navigate or even edit tiddler ( tm-edit-tiddler ) , when you can rename it.
Before opening it to edit where you could rename it, the $savetitle remains valid and you could use it to perform other operations on the new tiddler, although much can be done within the  action-createtiddler  such as setting any field value. 

Otherwise; accept or generate the new tiddler name before  $action-createtiddler  
 
Tones

Mark S.

unread,
Dec 17, 2020, 11:18:14 PM12/17/20
to TiddlyWiki
On Thursday, December 17, 2020 at 7:33:30 PM UTC-8 TW Tones wrote:


Otherwise; accept or generate the new tiddler name before  $action-createtiddler  
 

This somewhat obviates the utility of the $savetitle attribute, since the results are not available  until the containing process is completed.

So, for instance, you couldn't catch use $savetitle to create a reference in another tiddler to the newly created tiddler until the process is done. Meaning, at best, that the user has to push a button for a second time for no apparent reason. (not apparent to the user, in any case).



 

Michael Wiktowy

unread,
Dec 18, 2020, 1:02:34 AM12/18/20
to TiddlyWiki
The problem is highlighted by something like this:

\define dropaction()
<$action-createtiddler $basetitle=<<actionTiddler>> />
<$list filter="[all[tiddlers]search:title<actionTiddler>sort[created]last[]]" variable="lastcreated">
<$fieldmangler tiddler=<<lastcreated>>>
<$action-sendmessage $message="tm-add-tag" $param=<<currentTiddler>>/>
</$fieldmangler>
</$list>
\end

<$droppable actions=<<dropaction>>>Some area to drop on
</$droppable>

... this brute-force approach doesn't work and will tag the second from last one since the action-createtiddler doesn't create a tiddler until the entire action is done.

None of these work now but maybe one of these solutions could be adopted in the core:
1) the DroppableWidget could be made to act more like the ButtonWidget in that actions within the widget are triggered so <$droppable actions=<<second_actions>> >  <<first_actions>>  </$droppable> would work. Right now only <<second_actions>> trigger.

2) DroppableWidgets (and ButtonWidgets) could be make nestable with inner widgets completing before outer ones so that you can have constructs like:

<$droppable actions=<<nth_drop_action>>>
...
<$droppable actions=<<second_drop_action>>>
<$droppable actions=<<first_drop_action>>>Some area to drop on
</$droppable>
</$droppable>
...
</$droppable>

3) ActionCreateTiddlerWidget could have a variable scope that acts like <$fieldmangler> to do things like:
<$action-createtiddler $basetitle="Created Tiddler">
<<actions_that_use_currentTiddler_or_defined_variable_that_is_same_as_that_stored_in_$savetitle>>
</$action-createtiddler>

... however having the name won't help if the tiddler isn't created until the end.

Some potential RFEs ... none of which I have the skill to implement.

/Mike

TW Tones

unread,
Dec 18, 2020, 9:24:11 PM12/18/20
to TiddlyWiki
Folks,

I may be missing something here, or perhaps 5.1.23 has reverted (untested by me yet), but I cant help but feel these posts are miss-representing things somehow.

The drop actions do add complexity to this but inside a single button I have used createtiddler then referenced the save title as a variable and used it elsewhere.
However if one determines a base title that does not exist yet, then the save title will always be the same and you don't even need to access it. Just use the first title to used for base title. If multiple tiddlers are written they should receive a number increment tiddlername 1, tiddlername 2 etc... in which case they all have the prefix tiddlername. Knowing this if you want you can rename them. 

In the pre-release
<$button>
<$action-createtiddler $basetitle="Excerpt" $savetitle="$:/savedtitle" tags="Excerpt" text=<<actionText>> />
<$action-navigate $to={{$:/savedtitle}}/>
Go
</$button>

This works, and it can only do so if the $:/savedtitle is correct when the action-navigate is done.
So how can the OT of marks say? The title saved in $:/savetitle doesn't become available until AFTER the routine it is in finishes. This means it is too late to be used by other widgets inside of the same routine/macro.
If becomes available immediately after the createTiddler action how can this be true?

Tones


Mark S.

unread,
Dec 18, 2020, 10:47:53 PM12/18/20
to TiddlyWiki
Perhaps action-navigate works differently than action-setfield, or perhaps everything works differently with a drop action.

TW Tones

unread,
Dec 18, 2020, 11:04:56 PM12/18/20
to TiddlyWiki
Mark,

Maybe with drop action, but as you can see action navigate is only using a transclusion, I can even use  {{$:/savedtitle}}  in the button title or after.
With a qualified save title the last title can be stored indefinitely as well, so I find it hard to imagine.

What were you trying to achieve with the drop action?

I am currently experimenting with building a generic list handling tool, I already have buttons on the viewToolbar that accept drag, click and drop, and I do not recall this limitations.
Perhaps its the order the actions are executed or the difference between inline actions and actions=<<action-macro>>

Tones

Mark S.

unread,
Dec 18, 2020, 11:10:08 PM12/18/20
to TiddlyWiki
Ok, the navigation actually occurs AFTER the entire routine has finished. Inside the routine, the value of the saved tiddler is unavailable.

To see this, try this variation:

<$button>
<$action-createtiddler $basetitle="Secret" $savetitle="$:/savedtitle" tags="Excerpt" text="do you see me now 2?" />
<$action-setfield $tiddler="testtiddler" text={{$:/savedtitle}} />
<$action-navigate $to={{$:/savedtitle}}/>
Go
</$button>

testtiddler: {{testtiddler}}

When you press go, the contents of testtiddler will be the prior (if there were any) contents of $:/savedtitle, not the one's generated during the routine.

TW Tones

unread,
Dec 18, 2020, 11:28:47 PM12/18/20
to TiddlyWiki
Well here is my test on the pre-release.

<$button>
<$action-setfield $tiddler="$:/savedtitle" text="" />
<$action-createtiddler $basetitle="Secret" $savetitle="$:/savedtitle" tags="Excerpt" text="do you see me now 2?" />
<$action-setfield $tiddler="testtiddler" text={{$:/savedtitle}} />
<$action-navigate $to={{$:/savedtitle}}/>
Go
</$button>

testtiddler: {{testtiddler}} saved title {{$:/savedtitle}} $:/savedtitle [[testtiddler]]

It seems to me to be doing what is expected of it.
  • Each time I click it generates the tiddler and updates testtiddler with the current new title.
  • So yes the $:/savedtitle is available to the second setfield.
  • I clear the $:/savedtitle first as a demo but it is not necessary.
Tones

Mark S.

unread,
Dec 18, 2020, 11:56:10 PM12/18/20
to TiddlyWiki
Ok, I think I'm back to "doesn't work with dropping." Might have to revisit tomorrow.

Thanks!

Mark S.

unread,
Dec 19, 2020, 12:03:28 AM12/19/20
to TiddlyWiki
BTW, what I'm working on is a tool that will let you select your text in the view template, drag and drop it to the drop zone in the sidebar, and automatically insert a link or transclusion into the place in the viewtemplate where the original text occurred. In other words, it works like excision, but without being in edit mode.

Michael Wiktowy

unread,
Dec 19, 2020, 12:17:19 AM12/19/20
to TiddlyWiki
Try this:

<$button>
<$action-setfield $tiddler="$:/savedtitle" text="" />
<$action-createtiddler $basetitle="Secret" $savetitle="$:/savedtitle" tags="Excerpt" text="do you see me now 2?" />

<$action-setfield $tiddler="testtiddler" text={{$:/savedtitle}} />
<$fieldmangler tiddler={{$:/savedtitle}}>
<$action-sendmessage $message="tm-add-tag" $param={{$:/savedtitle}}/>
</$fieldmangler>

<$action-navigate $to={{$:/savedtitle}}/>
Go
</$button>

testtiddler: {{testtiddler}}

saved title {{$:/savedtitle}}

$:/savedtitle [[testtiddler]]

I think the problem occurs when you have to use fieldmangler to send messages. Fieldmangler seems to fire first before anything else.

You'd expect the tiddler created by action-createtiddler to be tagged with itself. It doesn't unless you run that same fieldmangler with actions= separately. With droppable you don't have that option. It will only run actions= macros.

/Mike

PMario

unread,
Dec 19, 2020, 4:55:40 AM12/19/20
to TiddlyWiki
@Mark Use button actions like this,

\define actions()
ALL action widgets come here
\end

<$button actions=<<actions>> >click</$button>

Otherwise you beg for trouble.

-mario

Michael Wiktowy

unread,
Dec 19, 2020, 9:39:26 AM12/19/20
to TiddlyWiki

@PMario

I guess the quirk is with <$fieldmangler> ... I think in particular if it has a transcluded tiddler=. It executes first ... even when everything is put into actions= as you suggest. But several workarounds were identified that either:

1) avoid using the add-tag message (and consequently avoided using fieldmangler) by concatenating tags using filters/transfusion/variables

or;

2) split action lists into two groups (possible only using the ButtonWidget) that are forces them to execute serially so that you can make fieldmangler go last.

/Mike

Mark S.

unread,
Dec 19, 2020, 9:46:51 AM12/19/20
to TiddlyWiki
I'm not using a button. I'm using droppable. So all actions are happening inside an action macro.

The button example was only an example, and I'm afraid has confused the issue. Ignore what happens with buttons.

Mark S.

unread,
Dec 25, 2020, 12:01:14 AM12/25/20
to TiddlyWiki
So now that 5.1.23, I can post the example I've been working on:


If you look at the code, you'll see that I have to use a tiddler that's made in advance of the drag/drop routine. The tiddler that's made during the routine is not available for use inside the routine.
Reply all
Reply to author
Forward
0 new messages