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

Unified Diff: views/controls/textfield/native_textfield_gtk.cc

Issue 5254011: Forward unhandled KeyEvents to WidgetGtk's HandleKeyboardEvent() in native textfields. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/views
Patch Set: Invoke HandleKeyboardEvent from OnKeyEvent() Created 10 years, 1 month 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: views/controls/textfield/native_textfield_gtk.cc
diff --git a/views/controls/textfield/native_textfield_gtk.cc b/views/controls/textfield/native_textfield_gtk.cc
index b52a50bbd22aac612229dbff80dc1316b25ed276..7ba95050e7ba0f76d8392bc0c9b2943fa64f2656 100644
--- a/views/controls/textfield/native_textfield_gtk.cc
+++ b/views/controls/textfield/native_textfield_gtk.cc
@@ -14,6 +14,7 @@
#include "views/controls/textfield/gtk_views_entry.h"
#include "views/controls/textfield/gtk_views_textview.h"
#include "views/controls/textfield/textfield.h"
+#include "views/widget/widget_gtk.h"
namespace views {
@@ -352,12 +353,23 @@ gboolean NativeTextfieldGtk::OnKeyPressEventHandler(
}
gboolean NativeTextfieldGtk::OnKeyPressEvent(GdkEventKey* event) {
+ bool handled = false;
+
Textfield::Controller* controller = textfield_->GetController();
if (controller) {
Textfield::Keystroke ks(event);
- return controller->HandleKeystroke(textfield_, ks);
+ handled = controller->HandleKeystroke(textfield_, ks);
}
- return false;
+
+ // If the controller doesn't handle the event, invite the widget's
+ // keyboard event handler. This picks up accelerators that would otherwise be
+ // lost to the widget.
+ if (!handled) {
+ WidgetGtk* widget = static_cast<WidgetGtk*>(GetWidget());
+ if (widget)
+ handled = widget->HandleKeyboardEvent(event);
+ }
+ return handled;
James Su 2010/12/02 08:37:24 This approach can cause problem as it handles a ke
}
// static
« 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