buttonClicked() fires when user presses return/enter key?


#1

I’m not sure how this is happening, but inside Cubase, if I press the return key my buttonClicked() function is called. Never noticed that before. It happens whether I have PluginWantsKeyFocus checked or not.

How can I disable this behavior?

Thanks.


#2

this is a problem, i could only solve this only via setting this on every component (also nested components)

setWantsKeyboardFocus(false);
setMouseClickGrabsKeyboardFocus(false);


#3

Interesting.

Why would this be considered normal behavior?

And thanks for the quick reply.


#4

you could add this to your plugin gui component, which iterate through all child (and nested child) objects

just call disableAllButtonsKeyboardFocus() in the constructor

void disableAllButtonsKeyboardFocus()
{
    disableAllButtonsKeyboardFocus(*this,*this);
}

void disableAllButtonsKeyboardFocus(AudioProcessorEditor& me,Component& component)
{
    for (int i=0; i<component.getNumChildComponents(); i++)
    {
        Component* child=component.getChildComponent(i);
        child->setWantsKeyboardFocus(false);
        child->setMouseClickGrabsKeyboardFocus(false);
        me.disableAllButtonsKeyboardFocus(me, *child);
    };
}

#5

Thanks. That worked like a champ.

As I said before, I’m curious why this is the default component behavior.


#6

If you use the GUI without a mouse, it is normal behaviour to step the focus through the components via tab key. If the button has the keyboard focus, an enter key event would be considered a buttonClicked().
Otherwise there would be no way to use a GUI without a mouse/pointing device.
This behaviour is found in most GUI-s including browser websites etc.
Also for accessibility I think this is important to allow at least one alternative to using the mouse.


#7

I had a user report that when he pressed Return/Enter for a specific key command on Cubase, my plugin responded as if a random button had been pushed…basically calling buttonClicked(). I tried changing the PluginWantsKeyFocus and it still responded the same way.

What would be the correct way to deal with this?


#8

We’ve got this problem too … is it new, or have I never notice this before!?


#9

Apparently I’ve just never noticed it before. Is this a regular complaint from Cubase users who use Enter for something important DAW related…