Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed key event handling for OpenGL views on macOS #307

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

1ci
Copy link

@1ci 1ci commented Sep 15, 2023

  • Fixed Logic Pro & GarageBand not handling key events after resizing the view
  • Added support for flagsChanged
  • Implemented all key modifier flags on macOS for completeness

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.

- Fixed Logic Pro & GarageBand not handling key events after resizing the view
- Added support for flagsChanged
- Implemented all key modifier flags on macOS for completeness
@scheffle
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants