5

When plotting anatomy data with

AnatomyPlot3D[Entity["AnatomicalStructure", "LeftIndexFinger"], Method -> {"Tooltips" -> True}]

the respective tooltips are shown at the mouse pointer location

enter image description here

Is there a way to copy the content of the selected tooltip to the clipboard and paste it to another cell? I have seen other answered questions (like this), but there tooltips were generated for each item/entity separately. When plotting an AnatomyPlot3D with the tooltip method all tooltips are already included.

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
Kardashev3
  • 1,354
  • 11
  • 22

1 Answers1

7

You can do post processing on the anatomy plot with something like

ReplaceAll[
    AnatomyPlot3D[Entity["AnatomicalStructure", "LeftIndexFinger"],
        Method -> {"Tooltips" -> True}
    ],
    Tooltip[a_, b_] :> EventHandler[Tooltip[a, b],
        {"MouseClicked" :> CopyToClipboard[ToString[b, InputForm]]},
        PassEventsDown -> True
    ]
]

Clicking and dragging will move the 3D object without copying anything. Clicking an object with a tooltip and not dragging will copy the tooltip to the clipboard.

Jason B.
  • 68,381
  • 3
  • 139
  • 286
  • I tried that but it put a TextCell in my clipboard rather than a string. – Jason B. Jun 21 '22 at 16:29
  • How exactly do you get a string? Do you paste in between cells, creating a new cell, or within an already existing cell? I get different results from those two, and only one of them is usable: https://i.stack.imgur.com/7rXyc.png – Jason B. Jun 21 '22 at 17:18
  • I pasted between cells. It created an input cell with a string like Cell["\"foo\"", "Input"] and not a proper input cell with BoxData like Cell[BoxData["\"\<foo\>\""], "Input"]. If I paste in an existing cell, I get an inline cell. So I guess ToString is better. – Michael E2 Jun 21 '22 at 18:18
  • Hi Jason, this works great! Combined with a snippet from https://mathematica.stackexchange.com/questions/16925/extracting-the-coordinate-of-a-particular-point-of-interest-from-a-listplot I can display the selected structures right below the plot: clicks = {}; Column[{ReplaceAll[ AnatomyPlot3D[Entity["AnatomicalStructure", "LeftIndexFinger"], Method -> {"Tooltips" -> True}], Tooltip[a_, b_] :> EventHandler[ Tooltip[a, b], {"MouseClicked" :> AppendTo[clicks, ToString[b, InputForm]]}, PassEventsDown -> True]], Dynamic[clicks // TableForm]}] – Kardashev3 Jun 22 '22 at 09:54