summaryrefslogtreecommitdiffstats
path: root/views/view.h
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/view.h
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/view.h')
-rw-r--r--views/view.h32
1 files changed, 15 insertions, 17 deletions
diff --git a/views/view.h b/views/view.h
index ed4d4a0..f3c5b8e 100644
--- a/views/view.h
+++ b/views/view.h
@@ -514,7 +514,8 @@ class View : public AcceleratorTarget {
// Called on a view (if it is has focus) before an Accelerator is processed.
// Views that want to override an accelerator should override this method to
// perform the required action and return true, to indicate that the
- // accelerator should not be processed any further.
+ // accelerator should not be processed any further (in which case the key
+ // event is eaten).
virtual bool OverrideAccelerator(const Accelerator& accelerator) {
return false;
}
@@ -705,6 +706,19 @@ class View : public AcceleratorTarget {
// (Shift-Tab).
virtual void AboutToRequestFocusFromTabTraversal(bool reverse) { }
+ // Invoked when a key is pressed before the key event is processed (and
+ // potentially eaten) by the focus manager for tab traversal, accelerators and
+ // other focus related actions.
+ // The default implementation returns false, ensuring that tab traversal and
+ // accelerators processing is performed.
+ // Subclasses should return true if they want to process the key event and not
+ // have it processed as an accelerator (if any) or as a tab traversal (if the
+ // key event is for the TAB key). In that case, OnKeyPressed will
+ // subsequently be invoked for that event.
+ virtual bool SkipDefaultKeyEventProcessing(const KeyEvent& e) {
+ return false;
+ }
+
// Invoked when a key is pressed or released.
// Subclasser should return true if the event has been processed and false
// otherwise. If the event has not been processed, the parent will be given a
@@ -712,14 +726,6 @@ class View : public AcceleratorTarget {
virtual bool OnKeyPressed(const KeyEvent& e);
virtual bool OnKeyReleased(const KeyEvent& e);
- // Whether the view wants to receive Tab and Shift-Tab key events.
- // If false, Tab and Shift-Tabs key events are used for focus traversal and
- // are not sent to the view. If true, the events are sent to the view and not
- // used for focus traversal.
- // This implementation returns false (so that by default views handle nicely
- // the keyboard focus traversal).
- virtual bool CanProcessTabKeyEvents();
-
// Invoked when the user uses the mousewheel. Implementors should return true
// if the event has been processed and false otherwise. This message is sent
// if the view is focused. If the event has not been processed, the parent
@@ -1001,14 +1007,6 @@ class View : public AcceleratorTarget {
// associated with them (so the root view gets the keyboard messages).
virtual void Focus();
- // Invoked when a key is pressed before the key event is processed by the
- // focus manager for accelerators. This gives a chance to the view to
- // override an accelerator. Subclasser should return false if they want to
- // process the key event and not have it translated to an accelerator (if
- // any). In that case, OnKeyPressed will subsequently be invoked for that
- // event.
- virtual bool ShouldLookupAccelerators(const KeyEvent& e) { return true; }
-
// These are cover methods that invoke the method of the same name on
// the DragController. Subclasses may wish to override rather than install
// a DragController.