How to make a popup menu background transparent

Hi Wisers,

I want to make the background of my popup menu transparent , while it is white background now.
Even I commented all content of paint function in juce_PopMenu.cpp for test , its background became black other than transparent.


 void paint (Graphics& g)
        if (isOpaque())
            g.fillAll (Colours::white);

        getLookAndFeel().drawPopupMenuBackground (g, getWidth(), getHeight());

Can anyone give me a hint?


Comonents are transparent unless you tell them otherwise… You’ll need to ask a less vague question if you want a helpful answer.

If you’re talking about a component sub-class then Component::setColour() will typically be what you are looking for.

Hi jules,

I just updated description about my issue , pls help me out.


I think someone has asked about transparent menus before - do a search of the forum… Can’t remember what the outcome was.

I have done that by adding a method in the LookAndFeel class IsPopupMenuOpaque()I override this method in my LookAndFeel.

Then I have replaced the code in PopupMenu::Window ctor, I call:setOpaque (getLookAndFeel().IsPopupMenuOpaque());instead of setOpaque (true);

One more thing is that on win32 drop shadow does not handle correctly semi transparent window (at least it is the case with the version of Juce I am using), so I have to do remove drop shadows on Windows:

int MyLookAndFeel::getMenuWindowFlags() { //on win32 drop shadow does not handle correctly semi transparent window #if WIN32__ return 0; #else return ComponentPeer::windowHasDropShadow; #endif }

Hope this helps.

1 Like