MathGroup Archive 2012

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: How to create palette buttons with tooltips?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg124175] Re: How to create palette buttons with tooltips?
  • From: Leonid Shifrin <lshifr at gmail.com>
  • Date: Wed, 11 Jan 2012 17:21:39 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <201201111100.GAA13183@smc.vnet.net>

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




On Wed, Jan 11, 2012 at 2:00 PM, Szabolcs <szhorvat at gmail.com> wrote:

> 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?
>
>




  • Prev by Date: Re: Unit testing using imported data
  • Next by Date: Re: Integrate function defined by numerical integration
  • Previous by thread: How to create palette buttons with tooltips?
  • Next by thread: Re: How to create palette buttons with tooltips?