CallOutBox instead of PopupMenu for ComboBox


#1

Hello Jules,

I would like to show a CallOutBox instead of a PopupMenu when a user clicks inside a ComboBox. I have found two problems:

1. ComboBox::showPopup() should obviously be declared virtual.

2. In the CallOutBox constructor, there is the following line:

setAlwaysOnTop (juce_areThereAnyAlwaysOnTopWindows());

don't you think this should be

setAlwaysOnTop (true);

like PopupMenu does? Otherwise, if I open a CallOutBox from a modal dialog window, it is positioned between my main window and the dialog.


ComboBox with sub menus in the JUCE code
#2

ComboBox really was never designed to be able to use other types of popup component, it's full of implementation details that assume it uses a PopupMenu. I've no idea what would need to be changed to make it more flexible, but I doubt if it would be as simple as just making it possible to override showPopup.


#3

Well, with those two little modifications, I have something fully functional right now. I found easy to derive a class from ComboBox, I just have to load my popover object inside showPopup() and update ComboBox's selection at the end of the interaction. I never ask for a JUCE modification without knowing that it is actually effective :)


#4

Hmm.. Well, I guess I could make the method virtual.

Re: setAlwaysOnTop, no it definitely shouldn't always be set to true, as that won't be what's wanted in all situations. Maybe you just need to call toFront() after showing it?


#5

That would be great Jules, thanks!

I will try what you suggest about toFront() as soon as I can.


#6

It works fine!

Now I anxiously wait for the showPopup() method to become virtual... :)


#7

Thanks - I've done that now.


#8

Hi !


In a same way,
Can it be possible to let the struct ItemInfo and OwnedArray <ItemInfo> items protected instead of private.
This could allow showPopup() overloads to create menus with submenus for instance.

Thanks for your concern about this.

 


#9

No, sorry, that's for internal use only. If I made it public and people started writing subclasses that relied on it, then I'd be unable to change the way the class works internally in the future.


#10

OK

I understand that the internal representation of ComboBox::ItemInfo will change if you decide to add all new features from juce::PopupMenu items (like iconToUse itemTextColour...)

Perhaps one day, adding public structure MenuItemCommandInfo like ApplicationCommandInfo shared between PopumMenu and ComboBox will help.

Having a public const accessor on OwnedArray<MenuItemCommandInfo> ComboBox::items should help clients to customize showPopup() too.

Thanks anyway.

 

 

 

 

 

 


#11

That's right. If I was going to add new functionality to do this kind of thing, then it'd need to be thought about more carefully, integrated with other classes, etc.


#12

One thing to look out for is since you can't set the private menuActive member to true, showPopup() will be called on both mouseDown and mouseUp. In my case the effect was two identical popup menus exactly on top of each other. So it appeared the menu wasn't dismissed only on the second click.

--
Roeland