Buttons as PopupMenu items : mouse over issue


#1

It seems that when buttons are in a popupMenu, they never enter in their “mouse over” state.

I tried it with a TextButton and an ImageButton. Any ideas what can goes wrong with that ?

to test it, in the ButtonsPage of the widget demo, I replace the void buttonClicked (Button*) which is triggered by the animateButton with that :


    ScopedPointer<ImageButton> imageButton;
    ScopedPointer<TextButton> textButton;
    bool active = false;
    
    void buttonClicked (Button* button)
    {
        if (active)
            return;
        
        Image normalImage = ImageCache::getFromMemory (BinaryData::juce_png, BinaryData::juce_pngSize);
        Image overImage = normalImage.getClippedImage (Rectangle<int> (0, 0, 100, 50));
        
        imageButton = new ImageButton ("imagebutton");
        imageButton->setImages (true, true, true,
                                normalImage, 1., Colour (0x0),
                                overImage, 1., Colour (0x0),
                                Image(), 1., Colour (0x0),
                                0.f);
        
        textButton = new TextButton ("button");
        
        PopupMenu menu;
        
        menu.addCustomItem (1,
                            imageButton,
                            normalImage.getWidth(), normalImage.getHeight(),
                            false);
        
        menu.addCustomItem (2,
                            textButton,
                            normalImage.getWidth(), normalImage.getHeight(),
                            false);
        
        
        menu.showMenuAsync (PopupMenu::Options().withTargetComponent (button)
                            .withItemThatMustBeVisible (1)
                            .withMinimumWidth (100)
                            .withMaximumNumColumns (1)
                            .withStandardItemHeight (jlimit (12, 24, getHeight())),
                            ModalCallbackFunction::forComponent (popupMenuFinishedCallback, this));
    }
    
    static void popupMenuFinishedCallback (int result, ButtonsPage *dtc)
    {
        dtc->active = false;
    }