Dynamic is sometimes too aggressive for some purposes. You need to make sure Dynamic updates only when you are ready for new results. Besides, to ensure that Dynamic will have enough time to process your request it is sometimes a good idea to use SynchronousUpdating option. In the solotuion below you will see that instead of calculating the menu options inside the Popup Dynamic, these are calculated in the external Dynamic where the SynchronousUpdating option will avoid aborted calculations.
DynamicModule[{readyQ = False, menu2Options = {}, q = "", h = "",
optCnt = 0, pSize = {400, 100}},
Panel@
Column[{
PopupMenu[Dynamic[q,
(q = #;
readyQ = False;
optCnt++;
) &]
, ExampleData[]
, Style["Select One", Red]
]
,
Dynamic[
Refresh[
menu2Options = If[q === "", {}, Last[##] & /@ ExampleData[q]];
Column[{
If[ListQ@menu2Options,
PopupMenu[Dynamic[h,
(h = #;
readyQ = True;
optCnt++;
) &
]
, menu2Options
, Style["Select One", Red]
]
,
"No options found."
]
,
Pane[
If[readyQ, ExampleData[{q, h}], "Waiting for your selection."]
, ImageSize -> Dynamic[pSize]
, Scrollbars -> Automatic
]
}]
, TrackedSymbols -> {optCnt}]
, SynchronousUpdating -> Automatic
]
}
]
]
Dynamic@ExampleData[{q, h}]
(instead ofExampleData[Dynamic[q], Dynamic[h]]
) works (but ... slow ) $\endgroup$ExampleData[a,b]
should beExampleData[{a, b}]
, (2) the error message "Dynamic[q] is not a known collection for ExampleData" gives a hint:Dynamic[q]
andq
are quite different objects. The more important issue is updatingh
properly whenq
is changed so that the{q,h}
combination is a valid input forExampleData
so thatExampleData
is not called with an input like{"AerialImage", "CatFur"}
:). Maybe someone else can come up with a complete solution while I explore some approaches. $\endgroup$