summaryrefslogtreecommitdiffstats
path: root/views/controls
diff options
context:
space:
mode:
authorjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-14 04:28:07 +0000
committerjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-14 04:28:07 +0000
commitca13d804c304a61711352044022971ec39f9d4f8 (patch)
tree81e2f1039a317a4ba5177ec98d18a545c0ff9c94 /views/controls
parent921515182691bf105b404862bf80ae7dfc0e151e (diff)
downloadchromium_src-ca13d804c304a61711352044022971ec39f9d4f8.zip
chromium_src-ca13d804c304a61711352044022971ec39f9d4f8.tar.gz
chromium_src-ca13d804c304a61711352044022971ec39f9d4f8.tar.bz2
Clean-up of the accelerator code.
The View::CanProcessTabKeyEvents and View::ShouldLookUpAccelerator have both been replaced with a new method, SkipDefaultKeyEventProcessing. This new method provides for a view that has focus a way to prevent a key event from being processed for tab traversal or accelerators. Also, fixed a regression where the Ctrl-Tab accelerator was not working anymore when the omnibox was focused. BUG=11538 TEST=Thoroughly test accelerators, making sure they work when the page, the omnibox and the find-bar text-field have focus. Also test that tab traversal still work as expected in the browser and in the option dialog. Review URL: http://codereview.chromium.org/113307 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16037 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/controls')
-rw-r--r--views/controls/menu/chrome_menu.cc5
-rw-r--r--views/controls/menu/chrome_menu.h7
-rw-r--r--views/controls/text_field.cc11
-rw-r--r--views/controls/text_field.h2
4 files changed, 16 insertions, 9 deletions
diff --git a/views/controls/menu/chrome_menu.cc b/views/controls/menu/chrome_menu.cc
index 203fb88..a1a6809 100644
--- a/views/controls/menu/chrome_menu.cc
+++ b/views/controls/menu/chrome_menu.cc
@@ -23,6 +23,7 @@
#include "skia/ext/skia_utils_win.h"
#include "views/border.h"
#include "views/drag_utils.h"
+#include "views/focus/focus_manager.h"
#include "views/view_constants.h"
#include "views/widget/root_view.h"
#include "views/widget/widget_win.h"
@@ -998,6 +999,10 @@ void SubmenuView::ReleaseCapture() {
host_->ReleaseCapture();
}
+bool SubmenuView::SkipDefaultKeyEventProcessing(const views::KeyEvent& e) {
+ return views::FocusManager::IsTabTraversalKeyEvent(e);
+}
+
void SubmenuView::SetDropMenuItem(MenuItemView* item,
MenuDelegate::DropPosition position) {
if (drop_item_ == item && drop_position_ == position)
diff --git a/views/controls/menu/chrome_menu.h b/views/controls/menu/chrome_menu.h
index f19af15..6bb25c7 100644
--- a/views/controls/menu/chrome_menu.h
+++ b/views/controls/menu/chrome_menu.h
@@ -16,6 +16,7 @@
#include "base/task.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "views/controls/menu/controller.h"
+#include "views/event.h"
#include "views/view.h"
namespace views {
@@ -553,12 +554,12 @@ class SubmenuView : public View {
// not captured.
void ReleaseCapture();
+ // Overriden from View to prevent tab from doing anything.
+ virtual bool SkipDefaultKeyEventProcessing(const views::KeyEvent& e);
+
// Returns the parent menu item we're showing children for.
MenuItemView* GetMenuItem() const { return parent_menu_item_; }
- // Overriden to return true. This prevents tab from doing anything.
- virtual bool CanProcessTabKeyEvents() { return true; }
-
// Set the drop item and position.
void SetDropMenuItem(MenuItemView* item,
MenuDelegate::DropPosition position);
diff --git a/views/controls/text_field.cc b/views/controls/text_field.cc
index 0395af3..190be98 100644
--- a/views/controls/text_field.cc
+++ b/views/controls/text_field.cc
@@ -1163,18 +1163,19 @@ void TextField::AboutToRequestFocusFromTabTraversal(bool reverse) {
SelectAll();
}
-bool TextField::ShouldLookupAccelerators(const KeyEvent& e) {
+bool TextField::SkipDefaultKeyEventProcessing(const KeyEvent& e) {
// TODO(hamaji): Figure out which keyboard combinations we need to add here,
- // similar to LocationBarView::ShouldLookupAccelerators.
+ // similar to LocationBarView::SkipDefaultKeyEventProcessing.
if (e.GetCharacter() == VK_BACK)
- return false; // We'll handle BackSpace ourselves.
+ return true; // We'll handle BackSpace ourselves.
// We don't translate accelerators for ALT + NumPad digit, they are used for
// entering special characters.
- if (!e.IsAltDown())
+ if (e.IsAltDown() &&
+ win_util::IsNumPadDigit(e.GetCharacter(), e.IsExtendedKey()))
return true;
- return !win_util::IsNumPadDigit(e.GetCharacter(), e.IsExtendedKey());
+ return false;
}
void TextField::UpdateEditBackgroundColor() {
diff --git a/views/controls/text_field.h b/views/controls/text_field.h
index 3ae3ed4..6dda5db 100644
--- a/views/controls/text_field.h
+++ b/views/controls/text_field.h
@@ -94,7 +94,7 @@ class TextField : public View {
virtual void AboutToRequestFocusFromTabTraversal(bool reverse);
// Overridden from Chrome::View.
- virtual bool ShouldLookupAccelerators(const KeyEvent& e);
+ virtual bool SkipDefaultKeyEventProcessing(const KeyEvent& e);
virtual HWND GetNativeComponent();