1
$\begingroup$

The CreatingPalettes help file shows how to create a palette with special symbols:

CreatePalette[
  Grid[
    Partition[
        PasteButton[Style[#, 12], RawBoxes[#],ImageSize->24]&
      /@
        {"π", "E", "I", "∞", "°", "*", "/", "->", ":>", "==", 
         "!=", "<=", ">=", "∈", "∍", "¬", "∧", "∨", "⋃", "⋂"},
      5],
    Spacings->{0,0}]];

I am trying to create a palette that includes some special symbols, and I also want to include tooltips. But, if, for example, I replace "Pi" with Tooltip ["Pi", "3.14"], the tooltip 3.14 displays nicely, but when I click on Pi, the result includes the word Tooltip along with the label:

Tooltip["π", "3.14"]

I have tried every which way for several days to add tooltips that behave. Meanwhile I have added lots and lots of other features, but this one defies me. I know it can't be hard but ...

$\endgroup$
2
  • $\begingroup$ I just found a way to make this work, but it's convoluted. I'd prefer to hear of a more straight-forward answer. $\endgroup$
    – matrixbud
    Nov 16, 2016 at 4:47
  • 2
    $\begingroup$ I am not very familiar with palette construction, but I wonder if you would have more luck by wrapping PasteButton within Tooltip, instead of the other way round. Unfortunately I'm on mobile and can't test it myself. $\endgroup$
    – MarcoB
    Nov 16, 2016 at 4:48

1 Answer 1

0
$\begingroup$

The following approach seems top work. I have reduced your code to something more like a minimal working example.

With[{chrs = {"π", "E", "I", "∞"}, 
      tips = {"π tip", "E tip", "I tip", "∞ tip"}}},
  CreatePalette[
    Grid[
      {MapThread[
         Tooltip,
         {PasteButton[Style[#1, 12], RawBoxes[#1], ImageSize -> 24] & /@ chrs, 
          tips}]},
      Spacings -> {0, 0}]]];
$\endgroup$
2
  • $\begingroup$ This is very nice, and I see how it follows MarcoB's suggestion as well. I plan to use this if I can wrap all the additional structure and data that I have already built into my palette. I don't wish to lose all that effort. If not, at least I now have my own less straight-forward solution to use. I'll post back when I figure this out. Thank you both! $\endgroup$
    – matrixbud
    Nov 16, 2016 at 20:24
  • $\begingroup$ I was easily able to embed this in my current template, so this definitely solves my problem. Because I have multiple grids, I had to move your "with" statement inside your "CreatePalette" and "Grid" statements (and, actually, inside other wrapper statements I have), but it worked right "out-of-the-box". It would have taken me days, if ever, to understand how to move Tooltip in front of PasteButton, so I really appreciate your showing me how to do this. $\endgroup$
    – matrixbud
    Nov 16, 2016 at 22:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.