summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfinnur@google.com <finnur@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-23 04:32:34 +0000
committerfinnur@google.com <finnur@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-23 04:32:34 +0000
commitd06d9474d6e76ecc124f0e1063fdcbabd48d7844 (patch)
tree5bc144f077b55ee1f3a69a25f629660437db9392
parent1760972673ada52e7fae2827b16616451b5c6a2f (diff)
downloadchromium_src-d06d9474d6e76ecc124f0e1063fdcbabd48d7844.zip
chromium_src-d06d9474d6e76ecc124f0e1063fdcbabd48d7844.tar.gz
chromium_src-d06d9474d6e76ecc124f0e1063fdcbabd48d7844.tar.bz2
Fix 4830: We navigate back after closing the Save As dialog.
If you use Alt-Shift-T and the arrow keys to go to the Page menu and then launch the Save Page As dialog, we would navigate back after saving the page. This is because once we close the Save As dialog with Enter, focus goes to the Back button (which arguable is also wrong, see issue 5750) and it receives a KeyRelease(Enter), which causes us to navigate back right after saving the page. In Windows, pressing Enter while a button has focus clicks the button on KeyPressed, whereas we currently click the button on KeyRelease. This patch makes Chrome mimic native Windows behavior. We retain the current behavior for Space, however, which clicks on KeyReleased in both Chrome and Windows. BUG=4830 TEST=Native Chrome buttons should click buttons on KeyPress when using Enter and on KeyRelease when using Space. Review URL: http://codereview.chromium.org/16202 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7406 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/views/base_button.cc11
1 files changed, 9 insertions, 2 deletions
diff --git a/chrome/views/base_button.cc b/chrome/views/base_button.cc
index 6424f90..bd4987b 100644
--- a/chrome/views/base_button.cc
+++ b/chrome/views/base_button.cc
@@ -217,9 +217,16 @@ void BaseButton::NotifyClick(int mouse_event_flags) {
bool BaseButton::OnKeyPressed(const KeyEvent& e) {
if (state_ != BS_DISABLED) {
- if ((e.GetCharacter() == VK_SPACE) || (e.GetCharacter() == VK_RETURN)) {
+ // Space sets button state to pushed. Enter clicks the button. This matches
+ // the Windows native behavior of buttons, where Space clicks the button
+ // on KeyRelease and Enter clicks the button on KeyPressed.
+ if (e.GetCharacter() == VK_SPACE) {
SetState(BS_PUSHED);
return true;
+ } else if (e.GetCharacter() == VK_RETURN) {
+ SetState(BS_NORMAL);
+ NotifyClick(0);
+ return true;
}
}
return false;
@@ -227,7 +234,7 @@ bool BaseButton::OnKeyPressed(const KeyEvent& e) {
bool BaseButton::OnKeyReleased(const KeyEvent& e) {
if (state_ != BS_DISABLED) {
- if ((e.GetCharacter() == VK_SPACE) || (e.GetCharacter() == VK_RETURN)) {
+ if (e.GetCharacter() == VK_SPACE) {
SetState(BS_NORMAL);
NotifyClick(0);
return true;