ComboBox PopupMenu Opacity


#1

Is it possible to draw a translucent PopupMenu in a ComboBox? In my look and feel, giving PopupMenu::backgroundColourId a color with alpha < 1 lightens the background but apparently does not make it translucent.


#2

There’s certainly nothing to stop it working, though I’ve not set it up that way… I guess it’d just need tweaking so that the windows use setOpaque (false) if the background isn’t opaque, and then it should work.


#3

Yes, calling setOpaque(false) on the Window object created in PopupMenu::createMenuComponent works, but is there a reason why this not the default setting for pop-ups?


#4

It’s far less efficient in win32 to use a non-opaque window, so you should only setOpaque (false) if you really need the transparency.


#5

I’m also trying to do a Popup menu transparent, but I cannot. I’m not sure if here in this thread is the solution, because it doesn’t work for me. PopupMenu::setOpaque() and PopupMenu::createMenuComponent() don’t exist. I tried also use setOpaque(false) in the component that deploy the PopupMenu (a custom button), and in the Component that contains that custom button (with is opaque with few transparent lines and components on it), but nothing.

Please, would you mind write further info about this?


#6

All you need to do is to set PopupMenu::backgroundColourId to a semi-transparent colour, and it’ll all just work.


#7

Yes, that was my first attempt but I obtain an interruption when I try to open the menu in juce_DropShadower.cpp:

What I did was a CustomLookAndFeel class inheriting from LookAndFeel, and then in its constructor:

I didn’t overwrite any Popup drawing method in this CustomLookAndFeel class. :?


#8

Well, the assertion is quite right - the shadows won’t be perfect. But on windows it’s not possible to do the shadows correctly, so you can either ignore the assertion, or give up. If your colour is almost opaque, it’ll look fine.


#9

I understand, thanks for the nfo! :slight_smile: