Bug in ComboBox

Hello Jules,

your recent (Nov 15 2014) modifications to ComboBox broke the virtual showPopup() behaviour.

Since the private member menuActive is set to 'true' inside the private method showPopupIfNotActive() before it calls showPopup() and reset to 'false' inside the private popupMenuFinishedCallback() method that is only accessible to the default showPopup() method, if I override showPopup() I can only open the menu once.

Hmm. showPopup() probably shouldn't be public.. Why are you calling it directly rather than allowing the ComboBox to pop it up when needed?

Jules, you made showPopup() virtual following my request: http://www.juce.com/forum/topic/calloutbox-instead-popupmenu-combobox.

Yeah, I made it virtual, and it's fine to overload it. But I wouldn't recommend calling it directly.

Where do you read that I'm doing that?

I'm not calling it, it is redefined in a class derived from ComboBox!

I assumed you must be calling it directly because internally, everything calls showPopupIfNotActive(), which will set the flags correctly. Only a direct call to shopPopup would fail to set the flags AFAICT, and that doesn't happen anywhere in the juce codebase.

showPopupIfNotActive() only sets the menuActive flag to true.

As I tried to explain in my initial post, the problem is that the menuActive flag is only reset to false if you use the default showPopup() method, that does that through the popupMenuFinishedCallback().

If showPopup() is redefined, since menuActive is not directly or indirectly accessible outside of the ComboBox class, there is no way to reset it and thus showPopup() won't be called the next time showPopupIfNotActive() is called.

Ah.. sorry, I misread your original post. Ok, that's a valid point, but this is why I added the virtual method addItemsToMenu() - if you're creating a custom menu it's much better to just override that method rather than showPopup

No, since I'm using the redefined showPopup() method to display a popover based upon a CallOutBox. I'm using an entirely different widget and this is why I asked you to make showPopup() virtual.

Well, I give up - got any suggestions for things that aren't hacks that would do what you need?


I guess the possibility to reset menuActive from a ComboBox derived class? In one of those elegant ways you implement so well...

I'm afraid I can't think of an elegant one in this case..

I'm sorry I can't work on it now, I will review the code ASAP.

OK, it seems to me that the best solution would be to simply declare

static void popupMenuFinishedCallback (int, ComboBox*)

protected instead of private.

Adding hacky single-purpose protected methods is not the kind of thing I was looking for! ..but I just had a quick look and found a different way to refactor it that should do the trick for you and keep the interface clean!

Of course it didn't look so hacky to me, but since if you have found, as always, a better solution, better that way. Thank You.