Commit 59048c8c authored by Leonard Grey's avatar Leonard Grey Committed by Commit Bot

Mac: Bail on flagsChanged: if keycode is 0

flagsChanged: is under-documented, but in Apple's examples, the actual
key which causes the change flag is provided in the |keyCode| property
and |modifierFlags| is used to determine whether it's a keyup or keydown.

When sending command key combinations via AppleScript (and possibly other
methods), the system feeds us a flags changed event with modifier flags
set correctly for "Command down" but an unset key code. Since key code 0
is A, we interpret this as Cmd+A (select all) when no such thing was intended.

The correct event is sent as well (with, for example, key code 55 for left command),
so we should drop the key code 0 event instead of trying to intepret it.

Hopefully this change also fixes https://crbug.com/885163

Bug: 889618
Change-Id: Ibc8fe0216b917cc50a23c252209f2ac09a10edf9
Reviewed-on: https://chromium-review.googlesource.com/c/1259243Reviewed-by: default avatarElly Fong-Jones <ellyjones@chromium.org>
Commit-Queue: Leonard Grey <lgrey@chromium.org>
Cr-Commit-Position: refs/heads/master@{#596319}
parent 2a23e8b2
......@@ -865,6 +865,13 @@ ui::TextEditCommand GetTextEditCommandForMenuAction(SEL action) {
}
- (void)flagsChanged:(NSEvent*)theEvent {
if (theEvent.keyCode == 0) {
// An event like this gets sent when sending some key commands via
// AppleScript. Since 0 is VKEY_A, we end up interpreting this as Cmd+A
// which is incorrect. The correct event for command up/down (keyCode = 55)
// is also sent, so we should drop this one. See https://crbug.com/889618
return;
}
ui::KeyEvent event(theEvent);
[self handleKeyEvent:&event];
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment