Chromium Code Reviews| Index: ui/views/cocoa/bridged_content_view.mm |
| diff --git a/ui/views/cocoa/bridged_content_view.mm b/ui/views/cocoa/bridged_content_view.mm |
| index 15ac3500bc7c36ed0e51d48931e75860ac9ef2ce..b11bf6727f963a50e9c88d2f8e5298694de530a5 100644 |
| --- a/ui/views/cocoa/bridged_content_view.mm |
| +++ b/ui/views/cocoa/bridged_content_view.mm |
| @@ -507,6 +507,21 @@ ui::TextEditCommand GetTextEditCommandForMenuAction(SEL action) { |
| bool isCharacterEvent = keyDownEvent_ && [text length] == 1; |
| + // Pass the character event to the View hierarchy. Cases this handles (non- |
| + // exhaustive)- |
| + // - Space key presses on controls. Unlike Tab and newline which have |
| + // corresponding action messages, an insertText: message is generated for |
| + // the Space key (insertText:replacementRange: when there's an active |
| + // input context). |
| + // - Menu mnemonic selection. |
| + // Currently there seems to be no use case to pass non-character events |
| + // routed from insertText: handlers, to the View hierarchy. |
| + if (isCharacterEvent) { |
| + ui::KeyEvent charEvent = GetCharacterEventFromNSEvent(keyDownEvent_); |
|
tapted
2017/01/11 14:54:20
I only discovered it by chance, but there's a supe
karandeepb
2017/01/13 03:13:38
Alt+q causes [[event character] length] == 1 in my
tapted
2017/01/13 20:02:44
Acknowledged.
|
| + [self handleKeyEvent:&charEvent]; |
| + keyDownEvent_ = nil; // Handled. |
| + } |
|
tapted
2017/01/11 14:54:20
part of me is surprised we don't accidentally hand
karandeepb
2017/01/13 03:13:38
Reading the code, I think the flow on Mac is-
Inpu
tapted
2017/01/13 20:02:44
nothing seems too out of place yet.. but yes - som
|
| + |
| // Forward the |text| to |textInputClient_| if no menu is active. |
| if (textInputClient_ && ![self activeMenuController]) { |
| // If a single character is inserted by keyDown's call to |
| @@ -528,23 +543,6 @@ ui::TextEditCommand GetTextEditCommandForMenuAction(SEL action) { |
| } else { |
| textInputClient_->InsertText(base::SysNSStringToUTF16(text)); |
| } |
| - |
| - keyDownEvent_ = nil; // Handled. |
| - return; |
| - } |
| - |
| - // Only handle the case where no. of characters is 1. Cases not handled (not |
| - // an exhaustive list): |
| - // - |text| contains a unicode surrogate pair, i.e. a single grapheme which |
| - // requires two 16 bit characters. Currently Views menu only supports |
| - // mnemonics using a single 16 bit character, so it is ok to ignore this |
| - // case. |
| - // - Programmatically created events. |
| - // - Input from IME. But this case should not occur since inputContext is |
| - // nil. |
| - if (isCharacterEvent) { |
| - ui::KeyEvent charEvent = GetCharacterEventFromNSEvent(keyDownEvent_); |
| - [self handleKeyEvent:&charEvent]; |
| keyDownEvent_ = nil; // Handled. |
| } |
| } |