Button and KeyPress:return

Hi Julian, I have a Toggle button added as a custom component in an AlertWindow. (For a “Do Not Show Again”). The problem is, user’s are used to hitting return to dismiss the dialog(I have an “OK” button). Currently when they do this it dismisses the alertwindow AND set’s the Do not show again.

At first I tried clearShortcuts on the component, but that had no effect. The culprit is…

[code]
bool Button::keyPressed (const KeyPress& key)
{
if (isEnabled() && key.isKeyCode (KeyPress::returnKey))
{
triggerClick();
return true;
}

return false;

}[/code]

Any suggestions? I thought about removing the key listener but would like to add ‘spacebar’ as a keyshortcut for the toggle button.

To “FIX” (I’m not gonna bother with the keyboard shortcut for now)

setWantsKeyboardFocus(false); // Stops Button::keyPressed() from being called

But perhaps an option in Button that specifies(if any) a KeyShortCut to toggleClick would be a good idea?

Hmm. The toggle button should really consume the event and stop it reaching the parent. I’ll look into that.