steinbergmedia / vstgui

A user interface toolkit mainly for audio plug-ins
Other
850 stars 121 forks source link

Fixed key event handling for OpenGL views on macOS #307

Open 1ci opened 9 months ago

1ci commented 9 months ago

The acceptsFirstResponder, becomeFirstResponder and resignFirstResponder methods in the opengl class make it possible for keyboard events to be caught by the (parent) view, otherwise it doesn't work if we don't have them.

The line in CocoaOpenGLView::viewSizeChanged() fixes an issue in Logic Pro and GarageBand where when you change the view size, the key event handling stops working even though the opengl view is still the first responder. Making the parent view the first responder fixes this problem. When you click on the opengl view, it becomes the first responder again and key events work.

The flagsChanged: method can be useful for detecting the pressing of modifier keys without any other key being pressed simultaneously. For example, if the user presses the Option key by itself, your responder object can detect this in its implementation of flagsChanged. Source

I had to implement all key modifier flags on macOS for the fake/simulated keyUp event in flagsChanged to work properly: https://developer.apple.com/documentation/appkit/nseventmodifierflags

I have been testing this on Reaper, Ableton Live, Logic Pro and GarageBand.

scheffle commented 9 months ago

Thanks for the pull request. You've added the feature to handle modifier key down/up, but only for macOS. This is not desired as we'd like to have the same features on all supported platforms. Are you able to provide this for Windows and X11? The second smaller issue is that you did not format your code with clang-format. In the root of the repository is a .clang-format file on how the code should be formatted.