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

You can create a template, something like:

template <typename ComponentType>
class LeftClickOnly : public ComponentType
{
public:
    using ComponentType::ComponentType;

    void mouseUp(const MouseEvent& e) override
    {
        if(e.mods.isLeftButtonDown())
        {
            ComponentType::mouseUp(e);
        }
    }
    void mouseDown(const MouseEvent& e) override
    {
        if(e.mods.isLeftButtonDown())
        {
            ComponentType::mouseDown(e);
        }
    }
    void mouseDrag(const MouseEvent& e) override
    {
        if(e.mods.isLeftButtonDown())
        {
            ComponentType::mouseDrag(e);
        }
    }
};

Then use it like:
LeftClickOnly<ToggleButton> myToggle;
it also works for Sliders etc.
There might be other mouse methods you want to override, but this was sufficient for my needs.

1 Like