I have a PopupMenu
in a Manipulate
with items in it that are inapplicable in some cases, and rather than removing them, I would like to disable (just) those items that are inappropriate.
For example, I'd like to disable (not remove) everything in list
that is, say, less than the item selected in filter
:
Manipulate[
{filter, list},
{{filter, 1, "Filter:"}, {1, 2, 3, 4, 5, 6}, ControlType -> PopupMenu},
{{list, 1, "List:"}, {1, 2, 3, 4, 5, 6}, ControlType -> PopupMenu}
]
Is there a way to disable specific individual items in a PopupMenu
, without resorting to a custom control?
Answer
There's no way to do this that conforms fully to UI guidelines (at least not for OS X). For example, your "disabled" items will still highlight as you hover over them and will still react to selection (thought they will do nothing).
This is as close as you can get:
Manipulate[
{filter, list}
,
{{filter, 1, "Filter:"}, {1, 2, 3, 4, 5, 6}, ControlType -> PopupMenu} ,
{list, None} ,
Grid[{{"List:",
PopupMenu[
Dynamic[list, If[# < filter, , list = #] &],
# -> Dynamic[Style[#, If[# < filter, Gray, Black]]] & /@ {1, 2, 3, 4, 5, 6}
]
}}
]]
Comments
Post a Comment