diff options
author | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-03 22:00:37 +0000 |
---|---|---|
committer | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-03 22:00:37 +0000 |
commit | d1d1f9f14a63c8b8a6b882c5e9bf5f67eeb3d574 (patch) | |
tree | 1103bbdb29bb7f8608ceb6f4e226af72d13c0479 /chrome/browser/autocomplete/autocomplete_edit_view_win.cc | |
parent | d4ad1947465c74539226d34254537cfea9aa2e81 (diff) | |
download | chromium_src-d1d1f9f14a63c8b8a6b882c5e9bf5f67eeb3d574.zip chromium_src-d1d1f9f14a63c8b8a6b882c5e9bf5f67eeb3d574.tar.gz chromium_src-d1d1f9f14a63c8b8a6b882c5e9bf5f67eeb3d574.tar.bz2 |
Some previous refactoring I did of the accelerator code had introduced regressions (pressing ESC would close the dialog instead of closing an opened combo-box, pressing enter on a dialog with a focused link would not open the link).Looking at fixing these I realized the method View::OvverideAccelerator was not needed anymore as View::SkipDefaultKeyEventProcessing supersedes it.So I removed View::OvverideAccelerator. As a result I also ended up moving some Windows specific code from LocationbarView to AutocompleteEditViewWin.BUG=6900TEST=Open the option dialog, click on a combo-box to open the drop-down list. Press ESC, the drop-down list should be closed. Move the focus to a link (by pressing Tab). Press Enter, the link should be opened and the option dialog should not be closed. Make sure that accelerators (ESC, tab, key up/down...) still work ok in the omnibox)
Review URL: http://codereview.chromium.org/119016
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17544 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autocomplete/autocomplete_edit_view_win.cc')
-rw-r--r-- | chrome/browser/autocomplete/autocomplete_edit_view_win.cc | 50 |
1 files changed, 43 insertions, 7 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_win.cc b/chrome/browser/autocomplete/autocomplete_edit_view_win.cc index 3b5a61c..67f7245 100644 --- a/chrome/browser/autocomplete/autocomplete_edit_view_win.cc +++ b/chrome/browser/autocomplete/autocomplete_edit_view_win.cc @@ -887,14 +887,50 @@ void AutocompleteEditViewWin::PasteAndGo(const std::wstring& text) { model_->PasteAndGo(); } -bool AutocompleteEditViewWin::OverrideAccelerator( - const views::Accelerator& accelerator) { - // Only override <esc>. - if ((accelerator.GetKeyCode() != VK_ESCAPE) || accelerator.IsAltDown()) - return false; +bool AutocompleteEditViewWin::SkipDefaultKeyEventProcessing( + const views::KeyEvent& e) { + int c = e.GetCharacter(); + // We don't process ALT + numpad digit as accelerators, they are used for + // entering special characters. We do translate alt-home. + if (e.IsAltDown() && (c != VK_HOME) && + win_util::IsNumPadDigit(c, e.IsExtendedKey())) + return true; + + // Skip accelerators for key combinations omnibox wants to crack. This list + // should be synced with OnKeyDownOnlyWritable() (but for tab which is dealt + // with above in LocationBarView::SkipDefaultKeyEventProcessing). + // + // We cannot return true for all keys because we still need to handle some + // accelerators (e.g., F5 for reload the page should work even when the + // Omnibox gets focused). + switch (c) { + case VK_ESCAPE: { + ScopedFreeze freeze(this, GetTextObjectModel()); + return model_->OnEscapeKeyPressed(); + } - ScopedFreeze freeze(this, GetTextObjectModel()); - return model_->OnEscapeKeyPressed(); + case VK_RETURN: + return true; + + case VK_UP: + case VK_DOWN: + return !e.IsAltDown(); + + case VK_DELETE: + case VK_INSERT: + return !e.IsAltDown() && e.IsShiftDown() && !e.IsControlDown(); + + case 'X': + case 'V': + return !e.IsAltDown() && e.IsControlDown(); + + case VK_BACK: + case 0xbb: + return true; + + default: + return false; + } } void AutocompleteEditViewWin::HandleExternalMsg(UINT msg, |