Android Popup Menu


#1

How do you get the id of the item the user selects in a popup menu under Android? (Knowing that JUCE doesn’t allow the modal loops which means the method show() doesn’t work)

Thank you


#2

Nowhere the codebase uses PopupMenu::show() any more, so search for ANY use of a popup menu and you’ll find an example of how to do it.


#3

Another question that I will ask here in order not to create a new topic kind of similar.
I have an OptionsComponent class containing a show() method called when the user opens the Audio & Midi Settings. It used to create a modal dialog window in which we were adding a component, this way:

DialogWindow::showModalDialog (TRANS(“Options”), theTabbedComponent, NULL, Colours::lightgrey, true, true, false);

As we know, Android doesn’t allow modal. That is why I tried replacing showModalDialog by showDialog. Thus, the window opens but is empty. Apparently, the component is drown and then disappear when the program leaves the function. I tried to repaint the component until the close button is pressed this way:

DialogWindow::showDialog (TRANS(“Options”), theTabbedComponent, NULL, Colours::lightgrey, true, true, false);
while(!(this->DocumentWindow::getCloseButton()->isDown()))
{
theTabbedComponent->repaint();
}

but this makes the program to freeze. Do you have an idea of what I could do?

Thanks for your work Jules


#4

Just create your window, and use enterModalState to set it off, then return and let it get on with it. You can’t loop or block your thread waiting for it! I’m sure there are plenty of examples in the codebase, have a look.


#5

Hmm, it seems enterModalState() isn’t working, only runModalLoop() is having its effect.


#6

enterModalState definitely works.


#7

I’m getting an assertion in juce_PopupMenu.cpp in line 1474 when using an ordinary ComboBox… ?


#8

Hmm, I think that assertion’s wrong, I’ll sort it out, thanks!