Thanks for your patience so far, I really appreciate your help.
So, here’s what was trying to do and how I got there:
I set up a PageTemplate as described way above, with a $messagecatcher
calling a macro on intercepting tm-navigate
,
<$messagecatcher $tm-navigate=<<additional-link-actions>> >
The macro is this:
\define additional-link-actions()
<$action-log message="$messagecatcher in $:/mwi/ui/PageTemplate"
from=<<event-navigateFromTitle>>
to=<<event-navigateTo>>
modifier=<<modifier>>
list={{$:/StoryList!!list}} />
<$list filter="[<modifier>match[normal]]" variable="void" >
<$action-setfield $tiddler="$:/state/tab/sidebar--595412856" text="$:/mwi/ui/SideBar/Meta" />
</$list>
<$action-navigate $to=<<event-navigateTo>> />
\end
When a tiddler is actually navigated to (not just added to the river by pressing Ctrl), I want the sidebar to switch to a tab containing additional information on the tiddler. This sidebar tab gets the information about which tiddler is shown from $:/HistoryList!!current-tiddler
as @TW_Tones also suggested.
The mechanism basically works, but now newly opened tiddlers are always – no matter where the click originated – added to the end of the story (my setting for tiddlers opened from outside the river) instead of immediately after the navigateFromTitle
tiddler (my setting for tiddlers opened from within the river). $action-navigate
does not seem to pass on information about the click source. This can also be seen in the HistoryList which only contains the title of the target.
So I added this code:
<$list filter="[<event-navigateFromTitle>!is[blank]] [<tv-story-list>!contains<event-navigateTo>] +[nth[2]]" variable="void">
<$action-listops $tiddler=<<tv-story-list>> $subfilter="+[insertbefore:event-navigateFromTitle<event-navigateTo>move<event-navigateTo>]"/>
</$list>
When there is a navigateFromTitle
and the tiddler is not already in the story, it is added right after the source of the click. If the source is not in the story, the new tiddler is added at the end (logic of the insertbefore
operator). I added the code before the call to $action-navigate
so that the navigator widget would always find the target tiddler already present in the story.
Now, what I stumbled over yesterday, and found while typing everything up here, was a second $messagecatcher
with a similar purpose I had set up in the ViewTemplate and forgot about. Their interaction shifted the location of the new tiddler erratically. After I disabled that, everything seems to work as expected now. All the while keeping the extra code very minimal. Oh joy of joys!
I have to requests for the core developers, though:
- Please enable us to call
tm-navigate
with the $action-sendmessage
macro, to populate navigateFromTitle
, etc. directly. Or alternatively, extend the $action-navigate
to be able to pass on such information.
- Can someone explain to me how the browser navigation to a tiddler is done? Especially, how does the zoomin storyview know which tiddler to show, and how does it show that tiddler and hide the others?
Making me write this down was a great help. Thank you again!
Yaisog