Button to hide and show right and left sidebar simultaneously

In this wiki, I am using the both the default right sidebar and the leftbar by tw_Mat. I want to create a button which can show and hide both the sidebars together.

Here is what I tried.

 <$action-setfield $tiddler="$:/state/sidebar" text="yes" />
 <$action-setfield $tiddler="$:/state/LeftBar" text="yes" />

 <$action-setfield $tiddler="$:/state/sidebar" text="no" />
 <$action-setfield $tiddler="$:/state/LeftBar" text="no" />

But only the right sidebar is working with this code.
Also is it possible to do this with a single button instead of the two buttons I am using. Any suggestions?

@twMat any comments on why the left sidebar is not opened on clicking the button using the above code.

OK, the attached tiddler will make it so the LeftBar toggle toggles both the LeftBar and the regular sidebar.

If you want to hide the regular sidebar button, you can go to the core tiddler titled $:/core/ui/TopBar/menu and remove the tag $:/tags/TopRightBar from it.

Both tiddlers mentioned can be reset by simply deleting them (this makes the original shadow tiddlers kick in again)

$__plugins_TWaddle_LeftBar_Toggle.tid (2.1 KB)

1 Like

Instead of using the leftbar toggle button, can this functionality be made into a separate viewtoolbar or page control button. This is because sometimes, we may need to open leftbar or right sidebar alone independently. Is that possible ?

You mean to keep the two original buttons and introduce a third button located among either the tiddler tools or the page tools? (…and if it is a page tool, how would it be used when it toggles the very sidebar it is inside?)

Yes. This is to do independent toggling of both sidebars separately.

This is how my TW looks.

Since I use a modified version of right sidebar from JD whitespace theme, a vertical bar of pagecontrol buttons are visible always on the right edge of the screen. So it doesn’t matter whether the right sidebar is visible or not, the page control buttons are always visible.

OK, so delete the previous tiddlers and install the attached one instead.

You can retitle it freely and if you’re not happy with the icons showing you can change them by locating the transclude icons in the code. It is tagged $:/tags/ViewToolbar to make it into a toolbar button. I’m not familiar with the JD whitespace theme so if you’d rather want it as a sidebar button you’ll have to figure it out.

mybutton.tid (1.8 KB)

1 Like

Thank you @twMat That was a very quick and perfect solution. This is the updated demo https://sidebar-hide.tiddlyhost.com/

Can keyboard shortcuts be assigned to the leftbar toggle and also to the new button shared now?

Probably, but I’ve just never learnt about keyboard shortcuts so you’ll have to experiment youself. Do share if you solve it :slight_smile:

I have created one custom keyboard shortcut in the past. I will try to create one today night. Thanks for all the help.