I have recently been working on some custom view content. Whenever I open a tiddler, I can click different buttons to display various information about it, which relies on a state tiddler to manage the display.
I want to automatically clear this state tiddler when the tiddler is closed. I have already figured out the filter expression for the logic, but I am not sure how to use the eventcatcher widget to specifically listen for the tm-close-tiddler message and trigger the action.
[all[tiddlers]prefix[$:/state/node-buttosn/]removeprefix[$:/state/node-buttosn/]] -[[$:/StoryList]get[list]enlist-input[]]
tm-close-tiddler is not an event… it’s a message. Try using the MessageCatcherWidget.
You may need to modify the $:/core/ui/PageTemplate and put the $messagecatcher within the content of the $navigator widget (which normally handles the tm-close-tiddler message). Your $messagecatcher action will also need to resend the tm-close-tiddler message so that the normal $navigator widget handling will still be triggered.
-e
Is there a way to achieve this without modifying system tiddlers? I’m concerned that altering them might cause conflicts during future upgrades. Alternatively, is there a JavaScript solution that could handle this?
I tried modifying the system tiddlers, but I’m not sure if the issue is my code or a fundamental misunderstanding. My modified TiddlyWiki can no longer close tiddlers, even though I included the code to send the tm-close-tiddler message. I think I need more clarification and discussion on this—I still haven’t quite figured out how the $messagecatcher widget is actually supposed to be used.
I’ve found a simpler solution: creating a custom button to replace the default close button. The code is as follows:
caption: {{$:/core/images/close-button}} {{$:/language/Buttons/Close/Caption}}
created: 20260301092236369
creator: 马不前
description: {{$:/language/Buttons/Close/Hint}}
modified: 20260301092632580
modifier: 马不前
tags: $:/tags/ViewToolbar 自用按钮
title: more-buttons-close-enhance
\whitespace trim
<$button
tooltip={{$:/language/Buttons/Close/Hint}}
aria-label={{$:/language/Buttons/Close/Caption}}
class=<<tv-config-toolbar-class>>
>
<$action-sendmessage $message="tm-close-tiddler"/>
<$let stateID={{{ [[$:/state/node-buttosn/]addsuffix{!!title}] }}}>
<$action-deletetiddler $tiddler=<<stateID>> />
</$let>
<%if [<tv-config-toolbar-icons>match[yes]] %>
{{$:/core/images/close-button}}
<%endif%>
<%if [<tv-config-toolbar-text>match[yes]] %>
<span class="tc-btn-text">
<$text text={{$:/language/Buttons/Close/Caption}}/>
</span>
<%endif%>
</$button>
change the close button was going to be my answer, although it does not catch come close events, if it works for you it’s a good approach.