Button addShortcut bug or focus problem?


#1

Not sure if this is an actual bug, or something funny going on in my code, but I have a simple DrawableButton (used as a “play” button in a transport bar) which I want to enable/disable using the spacebar. In my transport playbar gui’s constructor I call

to have it listen to spacebar presses. This works perfectly until I mouse-click somewhere in the app/gui (including the button itself), and then it no longer responds to spacebar presses. In the meantime I’ve gotten around this by manually calling playButton->setToggleState from a keyPressed() callback in the parent component, but it seems like this may be unnecessary as playButton should just automatically be receiving the events?

Any ideas? I’m not sure if the issue is a focus problem on my side (as even when I click the button itself with the mouse, it no longer listens to the key events), or if its a minor bug which has slipped through the cracks.

As always, thanks!


#2

Sounds like a focus issue to me - a button can only pick up a shortcut key being pressed if no other components consume the key-event, so it sounds like something else is grabbing that spacebar key-down event first.