Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I use this code to pass on options to a custom function:

argument1 = 1;
listOfOptions = {"Option 1","Option 2", "Option 3"};
 customFunction[argument1, OPTION -> option], 
 {option, listOfOptions, ControlType -> "SetterBar"}]

This code allows me to pass in ONE option at a time to customFunction. If I click, say, on "Option 1", "Option 2" and "Option 3" get deselected. What should I do to be able to pass more than one option at a time? I want what the control type TogglerBar allows one to do, but I haven't been able to make it work with Manipulate?

share|improve this question

closed as too localized by István Zachar, Oleksandr R., whuber, belisarius, Mr.Wizard Mar 27 '13 at 4:40

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

ControlType requires symbols and not strings: ControlType -> TogglerBar should work. Also, your example is missing a bracket } in customFunction. –  István Zachar Mar 26 '13 at 12:51
@IstvánZachar Mmf you are right, stupid question... Without quotes it seems to work, and with quotes no error is thrown but it behaves like SetterBar. –  su1 Mar 26 '13 at 13:00
It only works as a SetterBar without the quotes because for a certain number of options the default is SetterBar. Try it with Manipulate[option, {option, {1, 2, 3, 4, 5, 6}}] to see that the default for n > 5 options is PopupMenu. Manipulate is a smart guy (or at least it wants to look like one). –  István Zachar Mar 26 '13 at 13:07
I think you've asked good questions. Mathematica leaves all of us with lots to learn. This site helps all of learn more. Welcome and thanks for participating. –  Jagra Mar 26 '13 at 13:16

1 Answer 1

This works with TogglerBar.

argument1 = 1;
listOfOptions = {"Option 1", "Option 2", "Option 3"};
Manipulate[customFunction[argument1, OPTION -> option], 
 Dynamic@TogglerBar[Dynamic@option, listOfOptions]]

Or as an alternative, you can use ListPicker (new in v9).

Dynamic@ListPicker[Dynamic@option, listOfOptions]

But, as per my prior question here, be forewarned that it has a bug in that if you have the Window->Show Ruler set, the highlights of clicked items are shifted up a row.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.