I would like to implement tm-close-tiddler so when I open one tiddler, the current tiddler closes. Essentially, I am trying to implement my own version of Single Tiddler Mode.
Zoomin may display a single tiddler at a time, but it doesn’t close them. My project requires that when I return to the tiddler it returns to the original unopen state. I have been playing around with tm-close-other-tiddlers and tm-close-all-tiddlers, but so far no luck.
I have tried something like this in the $:/core/ui/AdvancedSearch/Standard tiddler:
\define close(msg)
<$action-sendmessage $message="tm-close-tiddler"/>
or
<$action-sendmessage $message="tm-close-all-tiddlers"/>
or
<$action-sendmessage $message="tm-close-other-tiddlers"/>
\end
<$messagecatcher actions=<<close>>>
...
</$messagecatcher>
At this point, I am wondering if there there is a way to trigger an action when clicking on a link.
@RedAsset I am confident what you want is possible. There may be an issue about where the action is listed eg in button widget params “message=tm-message” within a macro in actions=<<your-actions>> or in the body of the button <$action-sendmessage message=..
This is already occurring in the core where links generate the <$action-navigate $to="tiddlername"/> or as is often the case as within the list widget story and history mechanism. This means the message catcher can catch tm-navigate from regular links.
It is also possible to wrap the listing of links with the MessageCatcherWidget and trap tm-navigate and add the additional action.
Are you providing the list of links, or do you want to do it with all links?
I am trying to wrap the MessageCatcherWidget around all the links generated in the search results ($:/core/ui/AdvancedSearch/Standard). Additionally, I would do the same for all the links generated in the tabs in the sidebar. I figure once I figure out how to do one, the rest will fall into place. I realize that your time is limited, but I do appreciate all the help I can get.
In side a custom clone of $:/core/ui/PageTemplate I wrapped it in a message catcher widget, this example puts a message into the developer console, unfortunately it did not work.
I then did a minimal example that wraps the content of the contents tab, This works, on tiddlywiki.com, but I wont share it as below has better;
You can alter what occurs in the caught-actions and current tiddler is available but you may need to pass other variables if needed, however the console suggests most are available.
We then need to find where to wrap any list of links to capture navigation from them and wrap that. This package edits $:/core/ui/PageTemplate/sidebar and seems to capture any link in the sidebar.
I think I found something that might work.
I have modified tiddler $:/core/ui/ListItemTemplate from this:
<div class="tc-menu-list-item">
<$link />
</div>
To this:
\define link()
<$link />
\end
<div class="tc-menu-list-item">
<$button>
<$action-sendmessage $message="tm-close-all-tiddlers"/>
<$action-navigate $to=<<link>>/>
/* needs link text */
</$button>
</div>
This will navigate to a missing tiddler called: <$link />, but this does close all tiddlers. I just need to find away to convert that <$link /> into text.
Bricked means turn it into a brick. Bricks can’t do anything except sit there.
Just check if there are other consequences of this change. We do try and avoid changing core tiddlers because they may be missed during upgrade, but we do what we need to do.
@RedAsset: Check out this discussion for ways to execute actions on any navigation clicks, either from links, searches, the “Recent” tab or everywhere else: https://talk.tiddlywiki.org/t/executing-actions-on-navigation-clicks/2530
Here, the goal was to switch to a certain sidebar tab with every navigation event, but it might as well be used to close the previous tiddler, using the code you already have.
This way you’d only need to change your wiki in a single place instead of modifying links, wrapping search results and so forth. This will be helpful when maintaining the code or tweaking the behavior.
Have a nice day
Yaisog
I would recommend creating an alternate page layout that has custom handling for the tm-navigate widget message using the $messagecatcher widget, for a more reliable solution with less tweaking of the core code needed.
Every time navigation occurs to a tiddler, you want to replace the storylist instead of updating it.
The concept should be transferrable to your customized wiki. If you implement this as an alternative layout instead of tweaking the default Page Template, you can use the layout switcher to resort to the default page template if the customisations go awry, thus avoiding the possibility of bricking the wiki.
Note that you can also wrap custom CSS in wikitext such that it is only active when a particular layout is active.
a button to create a new tiddler, additionally containing
successfully opens the new draft tiddler, which is great for my usage, thanks @RedAsset and @saqimtiaz !
the page toolbar + button (control panel|appearances|toolbars|page toolbar) creates the draft (you can see it in history) but does not swap to it, possibly because it doesn’t close existing tiddlers first? maybe there is a solution without changing the core – e.g. adding a new toolbar button? https://tiddlywiki.com/#Creating%20new%20toolbar%20buttons