I want to display a graph with additional information and further information to appear in popups. Based on prior discussions here, I am trying to use ClickPane but I am running into the problem that the Dynamic@If statements necessary must be in Tables and remain unevaluated.
For example, the code
step = 2 Pi/6;
Graphics[{
Table[
{Blue, Tooltip[Disk[{Cos[x], Sin[x]}, .2], ToString@x]}
, {x, step, 2 Pi, step}]
}]
works fine, but if I try the code
step = 2 Pi/6;
DynamicModule[{pt = {0, 0}}, ClickPane[
Graphics[{
Table[
Dynamic@If[pt \[Element] Disk[{Cos[x], Sin[x]}, .2],
{Red, Disk[{Cos[x], Sin[x]}, .2], White,
Text[ToString@x, {Cos[x], Sin[x]}]}
, {Blue, Tooltip[Disk[{Cos[x], Sin[x]}, .2], ToString@x]}]
, {x, step, 2 Pi, step}]
}]
, (pt = #) &]]
then I get the error that If is not a graphics primitive.
Any ideas?
Per Kuba's suggestion, the code
step = 2 Pi/6;
DynamicModule[{pt = {0, 0}}, ClickPane[
Graphics[{
Table[With[{x = x1},
Dynamic@If[pt \[Element] Disk[{Cos[x], Sin[x]}, .2],
{Red, Disk[{Cos[x], Sin[x]}, .2], White,
Text[ToString@x, {Cos[x], Sin[x]}]}
, {Blue, Tooltip[Disk[{Cos[x], Sin[x]}, .2], ToString@x]}]]
, {x1, step, 2 Pi, step}]
}]
, (pt = #) &]]
works, but still unclear to me why.
Table[With[{x=xasDynamicisHoldAll. – Kuba Mar 22 '17 at 15:31