[TW5] Button template

115 views
Skip to first unread message

andrew harrison

unread,
Feb 27, 2016, 10:48:15 PM2/27/16
to tiddl...@googlegroups.com

Does anyone have any suggestions on how I could write a template for my format buttons where the highlighted word button would be what would change? 

[[$:/plugin/ajh/format/button]]:

\define lingo-base() $:/language/format/

 

<$button message="tm-button" tooltip=<<lingo hint##button>> aria-label=<<lingo caption##button>> class=<<tv-config-toolbar-class>>>

<$action-setfield $tiddler="$:/language/format/notify" $field="text" $value=<<lingo notice##button>>/>

<$action-sendmessage $message="tm-notify" $param="$:/language/format/notify"/>

<$list filter="[<tv-config-toolbar-icons>prefix[yes]]">

<span class="tc-format-small">

B</span>

</$list>

<$list filter="[<tv-config-toolbar-text>prefix[yes]]">

<span class="tc-btn-text">

<<lingo caption##button>>

</span>

</$list>

</$button>

Scott Simmons (Secret-HQ)

unread,
Feb 27, 2016, 11:26:44 PM2/27/16
to TiddlyWiki
Would it work to create a macro that could generate each button based on a parameter?

E.g.:

\define format(button)
<$button message="tm-button" tooltip=<<lingo hint##$button$>> aria-label=<<lingo caption##$button$>> class=<<tv-config-toolbar-class>>>
<$action-setfield $tiddler="$:/language/format/notify" $field="text" $value=<<lingo notice##$button$>>/>
<$action-sendmessage $message="tm-notify" $param="$:/language/format/notify"/>
<$list filter="[<tv-config-toolbar-icons>prefix[yes]]">
<span class="tc-format-small">
<span class="text-transform:capitalize;">$button$</span></span>
</$list>
<$list filter="[<tv-config-toolbar-text>prefix[yes]]">
<span class="tc-btn-text">
<<lingo caption##$button$>>
</span>
</$list>
</$button>

... so that you could display the button with a macrocall like <<format "button">>.

andrew harrison

unread,
Feb 28, 2016, 5:25:23 AM2/28/16
to tiddl...@googlegroups.com
That's exactly what I was looking for. Thank you for your feedback.  

--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/401a8d57-c4b3-4c2e-bd79-0b09fd092246%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Scott Simmons (Secret-HQ)

unread,
Feb 28, 2016, 6:17:35 AM2/28/16
to TiddlyWiki
Awesome!

(Did you get a chance to check out my tab source button solution in the other thread?  https://groups.google.com/d/msg/tiddlywiki/UAHlzJrZB5c/1aAswfeaHAAJ )

andrew harrison

unread,
Feb 28, 2016, 11:04:04 PM2/28/16
to tiddl...@googlegroups.com
Um, well, I thought it was almost perfect. After I tested it a bit I still have a slight problem. The tooltip comes up as "{{$:/language/format/hint##bold}}" instead of "make the selected text bold" from the dictionary tiddler. Any more suggestions?

On Sun, Feb 28, 2016 at 4:17 AM, Scott Simmons (Secret-HQ) <goo...@secret-hq.com> wrote:
Awesome!

(Did you get a chance to check out my tab source button solution in the other thread?  https://groups.google.com/d/msg/tiddlywiki/UAHlzJrZB5c/1aAswfeaHAAJ )

--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.

Scott Simmons (Secret-HQ)

unread,
Feb 28, 2016, 11:39:51 PM2/28/16
to TiddlyWiki
Hmmmm.  Is there a leading or trailing space in the dictionary tiddler causing problems?  Does the tooltip param have quotation marks that might be causing problems?

andrew harrison

unread,
Feb 29, 2016, 12:07:03 AM2/29/16
to tiddl...@googlegroups.com
No leading or trailing spaces. I can't use quotation marks if I want a lookup. It seems I can't use <<lingo>> for the tooltip or any defined macro. The only thing that seems to work is a transclusion dictionary lookup. I think I figured it out though. I still feel like something isn't quite right with the lingo thing. But since I still don't understand how lingo works I can't fully test it yet. Here is what I have now:

\define lingo-base() $:/language/format/
\define format(button)
<$button message="tm-$button$" tooltip={{$:/language/format/hint##$button$}} aria-label=<<lingo caption##$button$>> class=<<tv-config-toolbar-class>>>
<$action-setfield $tiddler="$:/language/format/notify" $field="text" $value=<<lingo notice##$button$>>/>
<$action-sendmessage $message="tm-notify" $param="$:/language/format/notify"/>
<$list filter="[<tv-config-toolbar-icons>prefix[yes]]">
<span class="tc-format-small">
<<lingo label##$button$>>
</span>
</$list>
<$list filter="[<tv-config-toolbar-text>prefix[yes]]">
<span class="tc-btn-text">
<<lingo caption##$button$>>
</span>
</$list>
</$button>
\end

On Sun, Feb 28, 2016 at 9:39 PM, Scott Simmons (Secret-HQ) <goo...@secret-hq.com> wrote:
Hmmmm.  Is there a leading or trailing space in the dictionary tiddler causing problems?  Does the tooltip param have quotation marks that might be causing problems?

--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
Reply all
Reply to author
Forward
0 new messages