Message Boards Message Boards

1
|
5281 Views
|
3 Replies
|
2 Total Likes
View groups...
Share
Share this post:

A question on using dynamic control objects

Reference the attached notebook (which is a toy example), I have a PopupMenu with three items (opt1). For each item in the PopupMenu there's a list of options that can be selected/deselected using a CheckboxBar (opt2). The point I'm stuck on is how to reset the list of selected options, opt2, from the CheckboxBar whenever the selected item (opt1) in the main PopupMen changes. Basically, I want to reset the list of items in opt2 to an empty lists {} whenever opt1 changes.

I could add a button to do this, but it seems unnecessary and I'd prefer not to have do so.

Any suggestions would be very much appreciated.


Solved

Have figured out a solution - see second attached notebook (ExampleNotebook2.nb).

POSTED BY: Ian Williams
3 Replies

Hi Lissa, Thanks for the suggestion. Much appreciated. All the best, Ian

POSTED BY: Ian Williams

Sorry, I hadn't seen the second notebook with your solution using DynamicModule. Nice!

Dear Ian, maybe the following solution is of interest to you. I don't know how to do it using DynamicModule, so I used Manipulate instead.

    opts = Association[
       "a" -> {"dog", "cat", "horse"},
       "b" -> {"car", "boat", "plane"},
       "c" -> {"apple", "pear", "banana"}
       ];
    Framed[Labeled[Column[
       {Manipulate[opt2 = {};
         Labeled[CheckboxBar[Dynamic@opt2, opts[opt1]], 
          Style["Select Options", Bold], Top],
         {{opt1, "b", ""}, {"a", "b", "c"}, PopupMenu}, Paneled -> False],
        Dynamic@opt2}], Style["Main Menu", Bold], Top], 
     Background -> LightBlue]
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract