4

I am trying to get buttons to work simultaneously with tooltips in 3D plots. Button has a Tooltip option, but it doesn't seem to work.

Consider code that creates a red point that turns green when clicked, and the point works with a tooltip.

In the following, Button works , but its Tooltip option does not.

DynamicModule[{b = 1}, Graphics[

Dynamic@Button[Style[Point[{0, 0}], {Red, Green}[[Mod[b, 2, 1]]], PointSize[0.1]], b++, Tooltip -> "hi"],

ImageSize -> Small]]

1

Thankfully, we can add the Tooltip function to make it work. Both Tooltip[Button[ and Button[Tooltip[ work. For example...

DynamicModule[{b = 1}, Graphics[

Dynamic@Tooltip[Button[Style[Point[{0, 0}], {Red, Green}[[Mod[b, 2, 1]]], PointSize[0.1]], b++], "hi"],

ImageSize -> Small]]

2

However, all three fail in some 3D plots.

We can see the button works, but its Tooltip option still fails.

DynamicModule[{b = 1},
 Dynamic@ListLinePlot3D[

{{2.1, Button[Style[2.9, {Red, Green}[[Mod[b, 2, 1]]]], b++, Tooltip -> "hi"], 2.8, 1.9}, {2.2, 2.7, 1.1, 2.2}},

PlotMarkers -> {Automatic, 0.05}]]

3

With Tooltip[Button[, Tooltip works but Button does not.

DynamicModule[{b = 1}, Dynamic@ListLinePlot3D[

{{2.1, Tooltip[Button[Style[2.9, {Red, Green}[[Mod[b, 2, 1]]]], b++]], 2.8, 1.9}, {2.2, 2.7, 1.1, 2.2}},

PlotMarkers -> {Automatic, 0.05}]]

4

With Button[Tooltip[, Button works but Tooltip does not.

5

How can I get such a button to work with a tooltip in ListLinePlot3D?

Michael E2
  • 235,386
  • 17
  • 334
  • 747
Just Some Old Man
  • 1,607
  • 1
  • 9
  • 12

1 Answers1

5

This may do it (it does what I think you might want):

DynamicModule[{b = 1}, 
  ListLinePlot3D[{{2.1, 
     Button[Style[2.9, {Red, Green}[[Mod[b, 2, 1]]] // Dynamic], b++, 
      Tooltip -> "hi"], 2.8, 1.9}, {2.2, 2.7, 1.1, 2.2}}, 
   PlotMarkers -> {Automatic, 0.05}]] /. 
 c : Button[p_, r___] :> 
  Button[Tooltip[p, Tooltip /. Options[c] /. Tooltip :> Sequence[]], 
   r]

Might be a bug, I suppose.

Alternative:

DynamicModule[{b = 1},
 Dynamic[
  ListLinePlot3D[{{2.1,
      Button[Style[2.9, {Red, Green}[[Mod[b, 2, 1]]]], b++, 
       Tooltip -> "hi"], 2.8, 1.9}, {2.2, 2.7, 1.1, 2.2}}, 
    PlotMarkers -> {Automatic, 0.05}] /. 
   c : Button[p_, r___] :> 
    Button[Tooltip[p, Tooltip /. Options[c] /. Tooltip :> Sequence[]],
      r]
  ]]
Michael E2
  • 235,386
  • 17
  • 334
  • 747