exitModalState parameter bottleneck?


#1

Hi everyone,

I am working on a ComboBox variant that allows multiple selections (e.g. a menu where you can select/deselect audio channels). In order to apply selection changes to a large number of items rapidly, it should be possible to keep the PopupMenu open and for example toggle the selection state of the current item using the space bar.

In principle this is possible to implement in the PopupMenu’s MenuWindow class, but here’s the caveat: as it seems, the only way to communicate from the MenuWindow to the ComboBox is via the exitModalState function, which only allows a single integer as a return value. Is this correct or am I overlooking something?

Ideally, I would like to have a way to interact with the application’s logic whenever I detect that the space bar was pressed (which probably has to be within within MenuWindow because that’s the only place where I can change the tick marks while the menu is open). If that is not possible, a way to send an array of integers via exitModalState would be nice, too. For now I got it to work by encoding the items whose state was toggled by using the integer as a bit-map, but that limits me to menus with a maximum of 32 items (well, for audio channels that’s ok, but there may be other uses where this maximum number of items may be a problem).

I should note also that I’m doing this for a client who has a JUCE v3 license, so if you know if there’s a difference between the current JUCE version and v3 in this regard, it would be nice to point it out (maybe it would motivate my client to update, too…).

Thanks a lot in advance for your hints and best regards,
Fritz


#2

Maybe it would be best to just use something else than ComboBox as your base Component since your requirements are so particular.


#3

Good idea. Is there any other component that opens up (when not in use the component should occupy only one line) but doesn’t use this modal window which seems to limit how I can communicate with the main component class?


#4

Maybe have a button (or whatever you want to always show) which when clicked, opens up a CallOutBox on which you set your custom Component. I’ve become quite a fan of CallOutBox myself lately. It’s a nice way to show a component which the user can dismiss by clicking outside of it or by pressing the Esc key. (It’s not a blocking modal component which returns a result, you will need to figure out some suitable scheme to pass information between all the components involved.)

https://www.juce.com/doc/classCallOutBox

If CallOutBox isn’t suitable, there probably is some other solution too…

Screen capture of various CallOutBoxes in my app :


#5

Thanks for the hint. I wasn’t aware of the existence of the CallOutBox class.