Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to create palette buttons with tooltips?

19 views
Skip to first unread message

Szabolcs

unread,
Jan 11, 2012, 6:01:22 AM1/11/12
to
What is the most convenient way to create palette buttons with tooltips that use the OS-wide tooltip delay?

Currently I am using

CreatePalette@
Tooltip[Button["Button", Appearance -> "Palette"], "Tooltip",
TooltipDelay -> Automatic]

But this seems like a lot of work (both TooltipDelay -> Automatic and Appearance -> "Palette" needed) just to get the behvaiour which could be expected as a default from a palette.

When I have several buttons, what's the simplest and most concise way to do this?

John Fultz

unread,
Jan 11, 2012, 5:22:13 PM1/11/12
to
The tooltip option can easily be migrated to the notebook level, where it'll
affect everything in the notebook:

CreatePalette[
Tooltip[Button["Button", Appearance -> "Palette"], "Tooltip"],
TooltipBoxOptions -> {TooltipDelay -> Automatic}]

Unfortunately, Button's Appearance option cannot benefit from a similar
treatment because Button[], by default, hardcodes the value of
ButtonBoxOptions->{Appearance->Automatic} at the ButtonBox level, which
overrides anything specified at the notebook level (there has been discussion
about changing this in future versions).

I would suggest just making a function called PaletteButton which creates a
Button with the right options.

Sincerely,

John Fultz
jfu...@wolfram.com
User Interface Group
Wolfram Research, Inc.

Leonid Shifrin

unread,
Jan 11, 2012, 5:23:14 PM1/11/12
to
Hi Szabolcs,

Why not use run-time code generation?

ClearAll[withPaletteButtons];
SetAttributes[withPaletteButtons, HoldFirst];
withPaletteButtons[code_, tooltipFunction_: First] :=
Unevaluated[code] /.
HoldPattern[Button[args__, opts : OptionsPattern[]]] :>
Tooltip[Button[args, Appearance -> "Palette",opts],
tooltipFunction[Hold[args]], TooltipDelay -> Automatic];

You use it as:

withPaletteButtons[
CreatePalette[{Button["Button1"], Button["Button2"]}]]


Cheers,
Leonid
0 new messages