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

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: Fix compile. 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 | ui/views/cocoa/bridged_native_widget_unittest.mm » ('j') | 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 9654302cd0326c8571193c5d9c0ae15a8bc70681..af62569c71421ffda83811c8ec3e060d0398d2f6 100644
--- a/ui/views/cocoa/bridged_content_view.mm
+++ b/ui/views/cocoa/bridged_content_view.mm
@@ -437,11 +437,22 @@ - (void)insertTextInternal:(id)text {
if (textInputClient_ && ![self activeMenuController]) {
// 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
+ // merged. We use ui::VKEY_UNKOWN as the key code since it's not feasible to
+ // determine the correct key code for each unicode character. Also a correct
+ // keycode is not needed in the current context. Send ui::EF_NONE as the key
+ // modifier since |text| already accounts for the pressed key modifiers.
tapted 2016/07/28 02:01:06 It might be worth raising a bug with the IME folks
+
+ // Also, 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));
+ } else {
textInputClient_->InsertText(base::SysNSStringToUTF16(text));
+ }
return;
}
« no previous file with comments | « no previous file | ui/views/cocoa/bridged_native_widget_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698