I’ve implemented an encoder component with a switch. This means I need to intercept both the clicking of the knob, and dragging it. I register the press on encoder release (and only if I don’t register a drag), to distinguish between clicks and drags.
class EncoderSwitch : public app::SvgKnob
{
void onButton(const event::Button &e) override
{
if (e.action == GLFW_RELEASE)
{
// If not dragging, it's a button press
if (!m_is_dragging)
{
// button press
m_pressed = true;
}
}
SvgKnob::onButton(e);
}
void onDragStart(const event::DragStart &e) override
{
m_is_dragging = true;
m_previous_value = getParamQuantity()->getValue();
SvgKnob::onDragStart(e);
}
void onDragMove(const event::DragMove &e) override
{
// do drag
}
}
The issue I have is that if I call SvgKnob::onButton(e); inside onButton() I get the GLFW_PRESS event but never get the GLFW_RELEASE event. If I remove the call to SvgKnob::onButton(e); I get both GLFW_PRESS and GLFW_RELEASE messages but dragging is not registered. Why is onButton() consuming the future GLFW_RELEASE and how can I prevent it?