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

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

Issue 5988010: focus reverse traversal was not working for TextfieldViews. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync Created 9 years, 12 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 | « views/controls/textfield/textfield.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: views/controls/textfield/textfield.cc
diff --git a/views/controls/textfield/textfield.cc b/views/controls/textfield/textfield.cc
index c4ab7996b449cdbd2e8b07b2284f5d903a6509b8..9da78ecd900ad97ae335ad234d3fe6ec67995a07 100644
--- a/views/controls/textfield/textfield.cc
+++ b/views/controls/textfield/textfield.cc
@@ -261,7 +261,7 @@ gfx::Size Textfield::GetPreferredSize() {
}
bool Textfield::IsFocusable() const {
- return IsEnabled() && !read_only_;
+ return View::IsFocusable() && !read_only_;
}
void Textfield::AboutToRequestFocusFromTabTraversal(bool reverse) {
@@ -290,6 +290,29 @@ void Textfield::PaintFocusBorder(gfx::Canvas* canvas) {
View::PaintFocusBorder(canvas);
}
+bool Textfield::OnKeyPressed(const views::KeyEvent& e) {
+ return native_wrapper_ && native_wrapper_->HandleKeyPressed(e);
+}
+
+bool Textfield::OnKeyReleased(const views::KeyEvent& e) {
+ return native_wrapper_ && native_wrapper_->HandleKeyReleased(e);
+}
+
+void Textfield::WillGainFocus() {
+ if (native_wrapper_)
+ native_wrapper_->HandleWillGainFocus();
+}
+
+void Textfield::DidGainFocus() {
+ if (native_wrapper_)
+ native_wrapper_->HandleDidGainFocus();
+}
+
+void Textfield::WillLoseFocus() {
+ if (native_wrapper_)
+ native_wrapper_->HandleWillLoseFocus();
+}
+
AccessibilityTypes::Role Textfield::GetAccessibleRole() {
return AccessibilityTypes::ROLE_TEXT;
}
@@ -316,12 +339,11 @@ void Textfield::SetEnabled(bool enabled) {
}
void Textfield::Focus() {
- if (native_wrapper_) {
- // Forward the focus to the wrapper if it exists.
- native_wrapper_->SetFocus();
- } else {
- // If there is no wrapper, cause the RootView to be focused so that we still
- // get keyboard messages.
+ // Forward the focus to the wrapper if it exists.
+ if (!native_wrapper_ || !native_wrapper_->SetFocus()) {
+ // If there is no wrapper or the wrapper din't take focus, call
+ // View::Focus to clear the native focus so that we still get
+ // keyboard messages.
View::Focus();
}
}
« no previous file with comments | « views/controls/textfield/textfield.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698