Programaticaly set active sidebar tab

61 views
Skip to first unread message

Devin Weaver

unread,
Jun 9, 2015, 8:23:55 AM6/9/15
to tiddly...@googlegroups.com
I've run into an edge case with the SideBar. I'm writing a plugin that reacts to user input (e.g. a button press) when that happens I want it to switch the active sidebar tab (e.g. recent tiddlers). Here is what I found:

  1. The SideBar tabs macro doesn't off any addressable buttons. In other words the user interaction is encapsulated in the macros defined in the SideBar tiddlers.
  2. The SideBar state is saved in a tiddler.
  3. Changing the text of the tiddler to point to a tab tiddler will change the active tab.
  4. The file name of the state tiddler ends in a unique hash that was created with $tw.wiki.getStateQualifier
  5. The $tw.wiki.search is unable to search for prefixes, regexps, or any globbing.
  6. There seems to be no way to discover (from a plugin) the actual tiddler title of the SideBar state tiddler.
How can I activate a known SideBar tab (by tiddler title) from a plugin?

The actual details of the use case is that I have a plugin that writes output to a known <div> that resides in a SideBar tiddler. When the user presses a button in any content tiddler it updates the SideBar tiddler. This all works. The trouble comes in when the active tab is on say Open or Recent and the output is hidden. When the user then press a content button it updates the SideBar tiddler but the user doesn't know. I want it to auto select the output SideBar tiddler so the user can see the result of their interaction. This makes sense because the button would be something like "calculate and activate tab". The SideBar is the correct place to put this output both layout wise and context wise. I feel strongly that this is the correct approach (attempting to avoid an XY problem here).

Felix Küppers

unread,
Jun 9, 2015, 9:02:20 AM6/9/15
to tiddly...@googlegroups.com
Hi Devin.

The problem here is that the tabs macro generates its state hash without
giving the api user any chance to control this. There is no clean way to
retrieve the state tiddler but you could use a prefix to retrieve a
tiddler that starts with "$:/state/tab/sidebar--"
($tw.wiki.filterTiddlers; or $tw.wiki.compileFilter + filter.call). The
first match should be the sidebar state tiddler...

-Felix


Devin Weaver

unread,
Jun 9, 2015, 10:45:01 AM6/9/15
to tiddly...@googlegroups.com
$tw.wiki.filterTiddlers Thank you that's the magic I was looking for!

Jeremy Ruston

unread,
Jun 9, 2015, 12:48:10 PM6/9/15
to TiddlyWikiDev
Hi Devin

The sidebar state tiddler is called $:/state/tab/sidebar--1835078512; that title will be consistent unless the page templates have been modified in a way that affects the "qualify" macro. The qualify macro works by concatenating the details of any transclusions in the ancestry tree:


To discover the titles of state tiddlers, I use the Advanced Search Filter tab and select "Recently modified tiddlers, including system tiddlers". Then switch the sidebar tabs and see the associated tiddler at the top of the list.

I think the sidebar tabs should probably in fact use a state tiddler with a static, fixed title; the only value in qualifying the state tiddler is in case the sidebar tabs are displayed multiple times in separate tiddlers. However, I'm not inclined to change it because of the backwards compatibility implications.

Best wishes

Jeremy.




--
You received this message because you are subscribed to the Google Groups "TiddlyWikiDev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywikide...@googlegroups.com.
To post to this group, send email to tiddly...@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywikidev.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywikidev/0fa6b578-d58e-4ae8-b909-1f56fcc85bb8%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Jeremy Ruston
mailto:jeremy...@gmail.com
Reply all
Reply to author
Forward
0 new messages