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 @@ - (void)insertTextInternal:(id)text { |
| 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_); |
| + [self handleKeyEvent:&charEvent]; |
| + keyDownEvent_ = nil; // Handled. |
| + } |
| + |
| // 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 @@ - (void)insertTextInternal:(id)text { |
| } 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 |
|
karandeepb
2017/01/11 06:00:58
Also, modified this comment.
|
| - // 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. |
| } |
| } |