Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(369)

Unified Diff: ui/views/cocoa/bridged_content_view.mm

Issue 2180873002: MacViews: Change insertTextInternal to correctly handle IME character input. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 625cb43c9498ed66f63e6742c7595db5f00ed6b2..39dae81d1ae28dcbc2ee6a4a3e18ebe4e0f6af36 100644
--- a/ui/views/cocoa/bridged_content_view.mm
+++ b/ui/views/cocoa/bridged_content_view.mm
@@ -438,10 +438,17 @@ - (void)insertTextInternal:(id)text {
// If a single character is inserted by keyDown's call to
// interpretKeyEvents: then use InsertChar() to allow editing events to be
// merged.
- if (isCharacterEvent)
- textInputClient_->InsertChar(GetCharacterEventFromNSEvent(keyDownEvent_));
- else
+ // Note we don't use |keyDownEvent_| to generate the synthetic ui::KeyEvent
+ // since for text inserted using an IME, [keyDownEvent_ characters] might
+ // not be the same as |text|. This is because |keyDownEvent_| will
+ // correspond to the event that caused the composition text to be confirmed,
+ // say, Return key press.
+ if (isCharacterEvent) {
+ textInputClient_->InsertChar(ui::KeyEvent([text characterAtIndex:0],
+ ui::VKEY_UNKNOWN, ui::EF_NONE));
tapted 2016/07/26 06:04:17 Perhaps comment about VKEY_UNKNOWN? E.g. before r
karandeepb 2016/07/27 04:47:32 Done. I guess this is fine, Else will have to expo
+ } else {
textInputClient_->InsertText(base::SysNSStringToUTF16(text));
+ }
return;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698