Custom Component in PopupMenu does not respond to mouseover on OSX


#1

Hi Jules, 
i'm having some issues with custom items in the PopupMenu.

I added a custom component to a PopupMenu which has some buttons on it. The buttons don't het highlighted when i hover over them with the mouse. The behaviour is correct on Windows.

I recreated the issue in the JuceDemo. I added the ColourSelector to a PopupMenu, when you move over the handles of the sliders they don't get highlighted.

Popupmenu with ColourSelector:

            PopupMenu popup;

            ColourSelector* colourSelector = new ColourSelector();

            colourSelector->setName ("background");

            colourSelector->setCurrentColour (findColour (TextButton::buttonColourId));

            colourSelector->setColour (ColourSelector::backgroundColourId, Colours::transparentBlack);

            popup.addCustomItem( 1, colourSelector, 300, 400, false );

            popup.showMenuAsync( PopupMenu::Options(), nullptr );

The behaviour is correct when using the CallOutBox.

But i don't like the way the CallOutBox positions itself and i also don't like the looks of it. I tried to let it look like the PopupMenu but that actually involves quite some hackery. So using the CallOutBox is not an option for me.

CallOutBox with ColourSelector:

            ColourSelector* colourSelector = new ColourSelector();

            colourSelector->setName ("background");

            colourSelector->setCurrentColour (findColour (TextButton::buttonColourId));

            colourSelector->setColour (ColourSelector::backgroundColourId, Colours::transparentBlack);

            colourSelector->setSize (300, 400);

            CallOutBox::launchAsynchronously (colourSelector, button.getScreenBounds(), nullptr);

#2

I added a custom component to a PopupMenu which has some buttons on it. The buttons don't het highlighted when i hover over them with the mouse.

Is this in a plugin?


#3

No it's not in a plugin. As i mentioned i added the code to the JuceDemo. I modified the code in the Dialogs demo so that when you click on the CallOutBox button a PopupMenu is shown instead of a CalloutBox to show the ColourSelector to illustrate te point. 


#4

The same problem is visible in the ColorSelectour inside the IntroJucer, also does not hightlight the sliders. 

Btw Keyboard input also does not work, try entering values in the slider text boxes... that's actually broken for a long time. odd that nobody else actually ever noticed that. 


#5

Ok, I see.

The thing is, the popup menu isn't designed to be used like this. It specifically disallows key focus, so that all cursor and enter keypresses can be grabbed and used to navigate. And on OSX it's standard behaviour that mouse-moves are only sent to focused windows.

Unless you actually have menu items in it that need triggering, then it's probably not what you should use to show a single custom component that needs extended interaction. Maybe just use a calloutbox that's been customised to remove the outline graphics?


#6

Ok i see, i know the focus issue on OSX, that's quite annoying actually but nothing you can do about it.

Well i wouldn't mind using the CallOutbox but i would like it to look like any other popup i have.

So some additions would be welcome.

- Some colourid's would come in quite handy, like background color id and outline color ids

- Option not to show arrow, when arrowsize is 0.0 it still shows a white line

- border size option, now the border will always be at least 20 pixels, or an option not to draw a border/outline.

Jules, What do you think. I know it's a lot to ask, i can alter the Juce myself of course.


#7

If all you want to do is to pop up your own window and have it go away when the mouse is clicked, you know that's basically just a few lines of code to do in your own class - just override inputAttemptWhenModal and make it delete your window. Have a look in CallOutBox::inputAttemptWhenModal, which is only a few lines, and probably even that's more complicated that you'd need to make it.


#8

All right, i guess creating my own custompopup is probably the way to go. I'll give it a try. thanx


#9

I eventually ended up adding a setMaxBorderSize to the CallOutBox class and used a custom look and feel, this way it behaves the same as the CallOutBox but looks like the PopUp.

I would suggest though using the CallOutBox in the IntroJucer so the ColourPicker can accept keyboard input on OSX. 

Actually it sounds odd that the CallOutBox can have proper mouse input and the PopupMenu cannot? Why not use the same trick you use in the CallOutBox for the PopupMenu, probably not as easy as it sounds? 


#10

Actually it sounds odd that the CallOutBox can have proper mouse input and the PopupMenu cannot? Why not use the same trick you use in the CallOutBox for the PopupMenu, probably not as easy as it sounds? 

I can't remember the details, but yes, it isn't as easy as it sounds! Or maybe it was just because the CalloutBox grabs keyboard focus, I don't remember.


#11

Jules, could you still have a look at the ColourPicker not being in a CallOutBox in the IntroJucer. Keyboard input does not work when working with colours. Can be quite annoying. I know the IntroJucer might not have high priority but we still use the IntroJucer every day for creating GUI components. 


#12

Sure, I've updated that now.