Alert sound on keypress - mac only

I have a simply plugin that I’m running in the standalone plugin wrapper. On Windows I can pass keypresses to the plugin without any issues, but on MacOS all I get is an alert sound? And no key listener callbacks are triggered. Is there something I must do in order to achieve the same behaviour as I see on Windows?

Do the demos work for you? Here, the DSPModulePluginDemo standalone receives keypresses correctly, as far as I can tell. I can move focus between textboxes with “tab”, enter new text, and interact with buttons and comboboxes from the keyboard. I do get an alert sound when pressing a key that is not handled by the plugin, though.

You could try sticking a breakpoint in ComponentPeer::handleKeyPress to check whether the event is making it through to the focused peer. If it is, you can then step through the function to find out why none of the components that you expect to handle the press are being given an opportunity to do so.

Thanks @reuk, and happy new year to all of you there. I can move focus between text boxes, and when the combobox has focus I can use move up and down to select things, but if I click anywhere else in the plugin window I get an alert sound for every single key I press. Is this different to the behaviour you see?

tryPassingKeyEventToPeer (event) keeps returning false, but I’m not sure why. The component on to which the key listener is registered has focus, according to a call to hasKeyboardFocus(true ) in its mouseDown method.

Also, should ‘target->keyListeners.size()’ return the number of KeyListeners across all components? Because in this case it always returns 1, even though I have multiple KeyListener derived components.

That sounds like the behaviour I’m seeing, yes. Maybe beeping on all unhandled keys is not a very pleasant user experience… I’ll see if there’s anything we can do about that.

:laughing: You’re probably right about that. Can you clarify whether or not the KeyListener array should be equal to the sum of all KeyListeners? If I know that at least I can dig a little further…

It looks to me like the peer will call getTargetForKeyPress() to find the most suitable component to handle the press. Then, the keyListeners array will be all of the listeners that have been attached to that specific component. Each of these listeners gets a chance to process the event, stopping once any listener returns that it has processed the event. If no listener processes the event, then the target component itself gets a chance to process the event.

I hope that helps!

1 Like

I’ve updated the mac ComponentPeer so that it should no longer beep on unhandled keypresses:

2 Likes