[TW5] Generic Popup Macro

170 views
Skip to first unread message

Tobias Beer

unread,
Sep 30, 2015, 4:31:24 AM9/30/15
to TiddlyWiki
Since I misposted that to a TW2 thread,
take this as some sort of announcement.

Here comes the pop macro:

Generic Popup @ tb5

I'm a bit surprised that
I haven't abstracted that into a macro yet,
— probably someone already did —
and that it's not in the core either
but rather a lengthy and complex explanation
as to how to go about creating a popup going along the lines of:
PopupMechanism + ButtonWidget + RevealWidget + QualifyMacro

Best wishes,

— tb

Bob Flandard

unread,
Sep 30, 2015, 6:33:31 AM9/30/15
to TiddlyWiki
Hello tb,

This is very nice. Can it have an option to popup on hover?

Maybe tooltup="$tooltip$" should be tooltip="$tooltip$" ?

All the best, Bob


Tobias Beer

unread,
Sep 30, 2015, 9:37:43 AM9/30/15
to tiddl...@googlegroups.com
Hi Bob,
 
This is very nice. Can it have an option to popup on hover?

I'd like that too, and will implement it
whenever the ButtonWidget will allow for it
or some other widget that registers events like "onhover".
So, for now that's a little more waiting.

Maybe tooltup="$tooltip$" should be tooltip="$tooltip$" ?

Thanks for a watchful eye. Fixed.

Best wishes,

— tb 

Jon

unread,
Oct 1, 2015, 1:16:31 AM10/1/15
to TiddlyWiki
Very nice!

Thanks
Jon

Jon

unread,
Oct 1, 2015, 1:30:44 AM10/1/15
to TiddlyWiki
Hi Tobias,

I don't think it works for tiddler names composed of more than one word.

It will open "Tiddler" and will also open this when you want to open "Tiddler name".

Regards

Jon

On Wednesday, 30 September 2015 09:31:24 UTC+1, Tobias Beer wrote:

Jon

unread,
Oct 1, 2015, 2:19:06 AM10/1/15
to TiddlyWiki
Also, Tobias, I don't know how to do this myself, but it would be good if the css were altered to create an opaque background for the pop-upped tiddler so the text can be displayed over text of the one underneath.

Thanks
Jon

Tobias Beer

unread,
Oct 1, 2015, 2:28:06 AM10/1/15
to tiddl...@googlegroups.com
Hi Jon,
 
I don't think it works for tiddler names composed of more than one word.
It will open "Tiddler" and will also open this when you want to open "Tiddler name".

Haha, I was fearing this could happen. :D

The simple example you are seeing is...

<<pop Click! Jack.jpg pretty>>

Notice how everything is strictly individual terms separated by a space.

Assume that you'd want to show Click me! and your image tiddler was Jack In The Sack.jpg,
then at least you needed to invoke the pop macro like so...

<<pop "Click me!" "Jack In The Sack.jpg" pretty>>

Notice how the parameters are now enclosed in quotes. That is always a more safe choice!

Even safer would be...

<<pop label:"Click me!" content:"Jack In The Sack.jpg" pop-class:"pretty">>

This way, if the stupid developer, being me in this case,
ever messes with the sequence of parameters,
your macro should still work in the future,
provided he didn't also rename them.

Here's a funny stumbling block...

<<pop Jack:jack:jack! Jack.jpg pretty>>

While you might think the first parameter would be "Jack:jack:jack!", it really is interpreted as...

1st parameter => name="Jack" & value = "jack:jack!"

You definitely want to make sure you use quotes
when your parameters come from a macro, e.g.:

\define mymacro(my-parameter)
<<some-other-macro "$my-parameter$">>
\end

Sometimes a macro parameter can even be passed having a quote,
so to avoid any problems you're even more safe doing...

\define mymacro(my-parameter)
<$macrocall name="some-other-macro" first-parameter-name="""$my-parameter$"""/>
\end

Notice how with the MacroCallWidget...
  1. you need to specifically name your parameters
  2. you can enclose your parameter using triple double-quotes
    so as to cater for any double-quotes safely being passed down
Best wishes,

— tb

Tobias Beer

unread,
Oct 1, 2015, 2:40:34 AM10/1/15
to tiddl...@googlegroups.com
Hi Jon,
 
Also, Tobias, I don't know how to do this myself, but it would be good if the css were altered to create an opaque background for the pop-upped tiddler so the text can be displayed over text of the one underneath.

I don't really understand why it would be transparent in the first place.
It seems to me that the core doesn't have any (meaningful) default styles for popups?

So, right now I am a little reluctant to add styles to the macro
because they won't cater everyone's desires and later on
make things more difficult for those to which they don't.

Best wishes,

— tb 

Jon

unread,
Oct 1, 2015, 3:29:19 AM10/1/15
to TiddlyWiki
Many thanks Tobias x 2

Regards
Jon

Tobias Beer

unread,
Oct 1, 2015, 3:31:53 AM10/1/15
to tiddl...@googlegroups.com
Hi Jon,
 
...and everyone else: Please update.

Also, Tobias, I don't know how to do this myself, but it would be good if the css were altered to create an opaque background for the pop-upped tiddler so the text can be displayed over text of the one underneath.
 
I added a stylesheet to provide meaningful defaults / fix problems with the core defaults, see...

Generic Popup @ tb5

PS: Also fixed another bug, where the state wouldn't be computed correctly due to me having renamed a parameter earlier. ;-)

Best wishes,

— tb

Jon

unread,
Oct 1, 2015, 11:51:25 AM10/1/15
to TiddlyWiki
HI Tobias,

Thank you very much for this - very useful.

Regards
Jon
Reply all
Reply to author
Forward
0 new messages