[FR] Buttons: add option to ignore clicks with right mouse button

I’m not sure you understood our use case Jules. here is a example :

you have a large component that contains many children buttons of all kind (textButtons, toggleButtons, etc…)
you want the user to be able to right click anywhere on that parent component to open a contextual menu.
at the moment, if the right click happens over a button, you will get the contextual menu, but the underlying button will also get clicked (and we don’t want that)

so we were more looking for something like a Button::setIgnoreRightClicks() or an additional flag to setInterceptClicks(). for now we have to inherits the buttons class.

I ended up doing something like that :

template <typename ButtonType>
struct ButtonIgnoringRightClick : public ButtonType
{
    using ButtonType::ButtonType;

    void mouseDown (const MouseEvent& e) override
    {
        if (e.mods.isPopupMenu())
            return;

        ButtonType::mouseDown (e);
    }

    void mouseUp (const MouseEvent& e) override
    {
        if (e.mods.isPopupMenu())
            return;

        ButtonType::mouseUp (e);
    }
};

ButtonIgnoringRightClick<TextButton> myTextButton;

1 Like