Triggering reveal widget with action widgets

Is there any way to invoke the reveal widget using keyboard shortcut?

A $reveal widget uses a state tiddler to track the opened/closed state of the widget. Typically, this is a tiddler containing one of two values, such as “yes” and “no”. Depending upon how the specific $reveal was written, sometimes the state tiddler is automatically removed when the $reveal is closed, such as when the $reveal is used to show a popup (with parameters type="popup" state=<<qualify "StateTiddlerTitle">>).

In a shortcut definition, you could use either an <$action-setfield> or <$action-deletetiddler> widget to control the state of a $reveal, as long as you know the name of the state tiddler. If the state tiddler name is generated using the <<qualify "StateTiddlerTitle">> macro, you can find the tiddler using a filter with [prefix[StateTiddlerTitle]] without having to know the specific “qualify” value that was appended to the end of the title.

-e

2 Likes

@EricShulman Is there any similar keyboard shortcuts in the core which I can compare and adapt to my needs

@arunnbabu81 I have moved this new line of questions to a new thread.

To help keep topics on the forum readable and searchable for others that may have the same question in the future, please do not ask new questions in a topic marked as solved and start a new topic for each new line of questioning.

The closest two I can think of are:

  • $:/core/ui/KeyboardShortcuts/change-sidebar-layout
  • $:/core/ui/KeyboardShortcuts/toggle-sidebar

Based on the $:/core/ui/KeyboardShortcuts/toggle-sidebar , I tried this code

<$list filter="[[$:/state/SampleReveal2]is[missing]] [{$:/state/SampleReveal2}removeprefix[yes]]" emptyMessage=""" <$action-setfield $tiddler="$:/state/SampleReveal2" text="show"/> """>
<$action-setfield $tiddler="$:/state/SampleReveal2" text="show"/>
</$list>

With this, I was able to show the contents of the reveal widget using keyboard shortcut I set, if it was already in hidden state .

Then I created another tiddler with this code - which hides the text when its already revealed.

<$list filter="[[$:/state/SampleReveal2]is[missing]] [{$:/state/SampleReveal2}removeprefix[yes]]" emptyMessage=""" <$action-setfield $tiddler="$:/state/SampleReveal2" text="hide"/> """>
<$action-setfield $tiddler="$:/state/SampleReveal2" text="hide"/>
</$list>

I gave different shortcuts for both.

But only one shortcut will function at a time. I will have to delete one of them for the other one to work

Any suggestions?

Try a single shortcut with the following action widget:

<$action-setfield $tiddler="$:/state/SampleReveal2" text={{{ [{$:/state/SampleReveal2}match[hide]then[show]else[hide]] }}}/>

If the the logic isn’t quite what you want, try swapping the hide and show.

2 Likes

That works well. thank you @saqimtiaz

@saqimtiaz When I implemented this suggestion by @EricShulman to add a <<qualify>> macro to the reveal widget I used, the keyboard shortcut aren’t working.

This is the code I used.

Any suggestions ?

Anyone knows what’s going wrong here

Someone can please help?

@arunnbabu81 I think you would benifit from using some debugging techniques to break down your problem further. Place extra text in your output to show which parts are active. Perhaps use dumpvariables or varname=<<varname>> in places to see intermediate values. Use a freebstanding qualify macro to see the title. Keep in mind qualify is sencitive to the current tiddler variable.

We are all volenteers here and whilst we all like to help the more time consuming it is to even read the question the more you ask us to do.

It will help if you have a bundle of tiddlers that if dropped on tiddlywiki.com replicate your problem then we can see the real and comprehencive code. You may find as I do when preparing such an example 50% of the time I solve it myself.

You are asking an aweful lot of the community and often, which is good but if you could do more to learn including more debug techniques and to help us help you. We will be able to help you even more.

1 Like

I will put a Json file once I am back home.

I ask questions here in the forum when I am sure that I can’t solve it myself. Even though I have been using tiddlywiki for last 2 years, I am still in the beginner stage when it comes to code stuff. Not that I haven’t tried to read, it’s not easy to understand especially since I don’t have any programming knowledge. I am a working doctor and I do tiddlywiki things when I am free. I am actually proud of whatever I have done with my tiddlywiki (it’s really beautiful and functional) with my limited knowledge - mostly by asking here or in the GitHub (for the plug ins I use)

2 Likes

Hi @arunnbabu81 thanks for sharing the background. I’m not always fast enough to respond to your questions, but appreciate being able to see over your shoulder as you grapple with TiddlyWiki. The highest goal of the project is to let ordinary people exercise the kind of autonomous power that is usually the domain of experienced software developers.

2 Likes

@arunnbabu81 I understand your position. And your use of tiddlywiki is impressive. however I am making suggestions that should save you time, let us respond quicker and reduce your overall effort. I expect you could find parallels in your own field of medicine, however we often need to look at things differently when acting outside our established knowledge.

I have uploaded my test wiki into tiddlyhost.

https://arsheth.tiddlyhost.com/

I have included the relevant tiddlers in the homepage.

Press “Alt+z” to reveal and hide the sidetabs (seen on the right side of tiddler body). The problem is that all tiddlers with reveal button show and hide the sidetabs simultaneously when we click the reveal button or use the keyboard shortcut on any of the tiddler. To overcome this Eric suggested to use qualify macro here

But after using the qualify macro, the keyboard shortcut doesn’t work. That is my current problem.

1 Like

@arunnbabu81 I am trying to reverse engineer you wiki to see where this all happens. I must admit I am unfamiliar with the horizontal layout.

I observe this reverses the value found in $:/state/SampleReveal2

[{$:/state/SampleReveal2}match[hide]then[show]else[hide]]

Alt-Z toggles the content of $:/state/SampleReveal2

Since this uses a state tiddler of a fixed name it will always toggle everywhere this state tiddler is in use.

ALt-Z is a global shortcut so it seems hard to determine if it would respond differently if used when different tiddlers are active. ie if you used state-tiddler=<<qualify string>>

I am trying to find tiddler containing the button that is visible on tiddlers that toggles the sidebar inside tiddlers. I believe this is the one you want to be active only on the current tiddler? Buttons/Sidetabs?

I will keep looking

  • I can’t toggle off the preview in tiddlers.
braintemplate without pagecover by Mat

This tiddler is responsible for that button

I also noticed that. I saw it after including the editor also in the sidetabs. Didn’t investigate it further. Will have to find the cause after this issue is settled.

How would you choose which tiddler to open the reveal widget in?

Tiddlywiki needs to know it, but it doesn’ know with extra javascript/plugin for detecting with events in ViewTemplate, without button click. (I don’t know if the core of tiddlywiki has this functionality)

So if I have to you the keyboard shortcut, I will have to avoid using the qualify macro. Only problem is that all the tiddlers with reveal widget will get revealed when I use the shortcut. But it not a big problem since I will maximum have two tiddlers filling the screen space with my settings. So its a workable compromise.