Button with PopupMenu mouse state stuck

Hello,

I’ve been having issues with this and it appears to be in the Juce Demo as well. Simply go to the Widgets section and click the “click for a popup menu…” button, whenever you get rid of the menu, the button will be stuck in the last state it was in. When you mouse over the button or click on a different button it gets fixed. In my code I’m opening the menu in a buttonClicked function. When I call isMouseOver on my button after the menu closes, it returns false as expected, yet if I call repaint it doesn’t repaint.

This is using the tip.

Thanks,
Sean

There was a bug related to menus that got fixed:

http://www.rawmaterialsoftware.com/viewtopic.php?f=2&t=9060

You might try rolling back to a commit before the fix for the bug mentioned in that link and see if your defect is reproducible.

The issue appears to have existed before the popup menu fix you’re referencing as well.

Thanks - that was an interesting one! Fixed now.

It seems to be working now on buttons where setTriggerOnMouseDown (true), but if you’re triggering your popup menu with mouse up it will get stuck on mouseOver.

That’s not what I’m seeing… It seems to work fine now AFAICT (?)

Weird… Well I just pulled again to make sure and I am indeed still getting this issue. I went into WidgetsDemo.cpp and did the following:

addAndMakeVisible (&menuButton);
menuButton.setBounds (10, 10, 200, 24);
menuButton.addListener (this);
//menuButton.setTriggeredOnMouseDown (true);

It’s quite subtle on the default look and feel but on my end it is definitely remaining in the wrong state. If I make a selection on the menu then mouse over the button, I will see no change in the button because it is already painted as mouse over. Moving out of the button will make it properly draw the mouse out state.

Thanks - another subtle edge-case… Try now.

Nice, looks good now.

Thanks Jules!

I’m sorry to wake up an ancient thread, but the fact is: this is still broken for a ShapeButton.

// declaration:
    ShapeButton menuButton {"ShapeButton",
                            Colours::red,
                            Colours::yellow,
                            Colours::green };     // layer operations

// component constructor
    Path p;
    p.addEllipse (0.0, 0.0, 20.0, 20.0);
    menuButton.setShape(p, false, true, false);
    
    addAndMakeVisible(menuButton);
    menuButton.onClick = [this] {
        PopupMenu menu;
        menu.addItem(1, "item 1");
        menu.addItem(2, "item 2");
        int sel = menu.show();
        if (sel)
        {
        //do stuff

        }
    };

The button gets stuck in the mouseover color after accessing the menu. If you use setTriggeredOnMouseDown() the problem is not there.

  • still broken.

As a temporary fix, you can set the button state to normal after the show menu line.