trying to combine actions in single button

140 views
Skip to first unread message

Dave

unread,
Oct 7, 2018, 3:08:13 PM10/7/18
to TiddlyWiki
I'm trying to add an action to the following button set that is currently functional:

\define yesnotag()
<$fieldmangler><$button message="tm-add-tag" param="Yes">{{$:/core/images/new-button}}</$button>
<$button message="tm-remove-tag" param="Yes">{{$:/core/images/delete-button}}</$button></$fieldmangler>
\end


This, when you add "<<yesnotag>> to a tiddler has a "+" sign button that adds a "Yes" tag to the tiddler and a (garbage can) button that removes the "Yes" tag.

The added functionality I want is for a certain SideBar tab to open if its not already open.

The following does just that in a separate button:
<$button> open "Homework" tab
   <$action-setfield $tiddler="$:/state/tab/sidebar--1835078512" text="Homework">
</$button>

It opens the "Homework" tab in the sidebar


My question is this: How can I get the sidebar tab "Homework" to open when you click either the buttons from the first <<yesnotag>> macro?

I've tried adding
<$action-setfield $tiddler="$:/state/tab/sidebar--1835078512" text="Homework">
in all the possible places in that macro I can think of and it always breaks the functionality of the original buttons, usually getting rid of the button image.

I suspect this might be one of those instances where there's more than one way to achieve something and I'm trying to combine them in the wrong way...

Is there a way to do this?

Thanks,
- Dave

Mat

unread,
Oct 7, 2018, 4:13:35 PM10/7/18
to TiddlyWiki
This http://gototab.tiddlyspot.com/ ... should guide you how to do it.

<:-)

Dave

unread,
Oct 7, 2018, 5:41:02 PM10/7/18
to TiddlyWiki

thank you Mat.  Yes, that method helped me to get this as a link that functions:

<$button class="tc-btn-invisible tc-tiddlylink">

  <$action-setfield $tiddler="$:/state/tab/sidebar--1835078512" text="Homework"/>
  click me
</$button>


but now I need to figure out how to attach that action to my pre-existing "+" and (garbage) buttons above.  It seems that no matter where I paste that action-setfield code into the other one it always breaks it.  Do I maybe have to convert the "<$button message=" method to an "action-setfield" method, and then just string the multiple actions in there?  I'll see if I can figure that out. not sure if the "fieldmangler" would work that way though...

Dave

unread,
Oct 7, 2018, 5:54:57 PM10/7/18
to TiddlyWiki
Okay, I figured it out.  This works:

\define yesnotag()
<$fieldmangler>
<$button message="tm-add-tag" param="Yes">{{$:/core/images/new-button}}<$action-setfield $tiddler="$:/state/tab/sidebar--1835078512" text="Homework"/></$button>
<$button message="tm-remove-tag" param="Yes">{{$:/core/images/delete-button}}<$action-setfield $tiddler="$:/state/tab/sidebar--1835078512" text="Homework"/></$button>
</$fieldmangler>
\end

I thought I had tried that before already, but it seems to work now.  The only difference I can see is before I never put a carriage return after <$fieldmangler> O_o

(I find that a really odd name: "fieldmangler", ha ha)

Reply all
Reply to author
Forward
0 new messages