tooltip within a link

89 views
Skip to first unread message

stevesuny

unread,
Dec 30, 2016, 2:35:20 PM12/30/16
to TiddlyWiki
Hi,

I've got this macro:
\define see(show,go)
<$link to=$go$ tooltip="hello">$show$</$link>
\end
I'd like to set the tooltip to a field of the $go$ tiddler (text, caption, tooltip, etc.) when the link is created with the <<see>> macro.

Thoughts?

Thanks...

//steve.



PMario

unread,
Dec 30, 2016, 3:38:02 PM12/30/16
to tiddl...@googlegroups.com
Hi Steve,

I did use a field named "tip" here.

\define see(show,go)
<$link to="""$go$""" tooltip={{$go$!!tip}}>$show$</$link>
\end


have fun!
mario

-edit: make it work with "tiddler names with spaces"

Eric Shulman

unread,
Dec 30, 2016, 3:39:56 PM12/30/16
to TiddlyWiki
On Friday, December 30, 2016 at 11:35:20 AM UTC-8, stevesuny wrote:
I've got this macro:
\define see(show,go)
<$link to=$go$ tooltip="hello">$show$</$link>
\end
I'd like to set the tooltip to a field of the $go$ tiddler (text, caption, tooltip, etc.) when the link is created with the <<see>> macro.

You are passing in "go" as a macro param.  As you clearly already know, this allows you to use $go$ to perform a *lexical substitution* so that the value of the "go" param in is inserted into the surrounding syntax.  The macro then "returns" the content, including the substitutions, for further processing by the TiddlyWiki parser.

To retrieve the value of the tooltip from a tiddler field (instead of the literal "hello" placeholder in your example), the syntax is:
   tooltip={{tiddlername!!fieldname}}
and, given that you have $go$ defined, you can write:
   tooltip={{$go$!!tooltip}}
where 'tooltip' is the desired field name.

Note: there's a small error in your macro code.  In the $link widget, you wrote:
   to=$go$

However, if $go$ is a tiddler title that contains spaces, this will break, as any text following the space will be treated as another widget parameter rather than being a part of the value assigned to the "to" parameter.  To make sure spaces in titles are properly contained, you should enclose the parameter value in quotes:
   to="$go$"

In addition, if the value of $go$ includes one or more double-quote characters, you would need to use the tripled-quotes, like this:
   to="""$go$"""
which ensures that any quote character(s) within the title will not be seen as a delimiter for the value, but will be treated as regular text content instead.

Putting it all together:
\define see(show,go)
<$link to="""$go$""" tooltip={{$go$!!tooltip}}">$show$</$link>
\end

enjoy,
-e

Eric Shulman
TiddlyTools / ELS Design Studios
InsideTiddlyWiki: The Missing Manuals



Eric Shulman

unread,
Dec 30, 2016, 3:43:11 PM12/30/16
to TiddlyWiki
On Friday, December 30, 2016 at 12:39:56 PM UTC-8, Eric Shulman wrote:
\define see(show,go)
<$link to="""$go$""" tooltip={{$go$!!tooltip}}">$show$</$link>
\end


CORRECTION: remove extra trailing quote at the end of the widget (left over from editing original example):
\define see(show,go)
<$link to="""$go$""" tooltip={{$go$!!tooltip}}>$show$</$link>
\end

-e

stevesuny

unread,
Jan 3, 2017, 9:15:00 PM1/3/17
to TiddlyWiki
Thanks Eric, that's exactly what I needed. much appreciated. //steve.
Reply all
Reply to author
Forward
0 new messages