Skip to content

macOS: Add synthetic empty on resignKey#9

Merged
murarth merged 2 commits intomurarth:modifiers-changed-window-eventfrom
rye:macos-synthetic-empty-on-resignkey
Feb 10, 2020
Merged

macOS: Add synthetic empty on resignKey#9
murarth merged 2 commits intomurarth:modifiers-changed-window-eventfrom
rye:macos-synthetic-empty-on-resignkey

Conversation

@rye
Copy link
Copy Markdown

@rye rye commented Feb 10, 2020

(And some commentary to document why it was necessary.)

rye added 2 commits February 10, 2020 17:17
This is so that we can interact with the ViewState directly from the
WindowDelegate.

Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
This logic is implemented similarly on other platforms, so we wish to
regain parity here.  Originally this behavior was implemented to always
fire an event with ModifiersState::empty(), but that was not the best as
it was not necessarily correct and could be a duplicate event.

This solution is perhaps the most elegant possible to implement the
desired behavior of sending a synthetic empty modifiers event when a
window loses focus, trading some safety for interoperation between the
NSWindowDelegate and the NSView (as the objc runtime must now be
consulted in order to acquire access to the ViewState which is "owned"
by the NSView).

Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
@murarth murarth merged commit 1227701 into murarth:modifiers-changed-window-event Feb 10, 2020
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