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

Side by Side Diff: ui/views/controls/combobox/combobox.cc

Issue 2299023003: Activate comboboxes (i.e. open dropdown menu) on Enter and Space. (Closed)
Patch Set: Created 4 years, 3 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 unified diff | Download patch
« no previous file with comments | « no previous file | ui/views/controls/combobox/combobox_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/controls/combobox/combobox.h" 5 #include "ui/views/controls/combobox/combobox.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 case ui::VKEY_HOME: 594 case ui::VKEY_HOME:
595 case ui::VKEY_PRIOR: // Page up. 595 case ui::VKEY_PRIOR: // Page up.
596 new_index = GetAdjacentIndex(model(), 1, -1); 596 new_index = GetAdjacentIndex(model(), 1, -1);
597 break; 597 break;
598 598
599 // Move to the previous item if any. 599 // Move to the previous item if any.
600 case ui::VKEY_UP: 600 case ui::VKEY_UP:
601 new_index = GetAdjacentIndex(model(), -1, selected_index_); 601 new_index = GetAdjacentIndex(model(), -1, selected_index_);
602 break; 602 break;
603 603
604 // Click the button only when the button style mode.
605 case ui::VKEY_SPACE: 604 case ui::VKEY_SPACE:
606 if (style_ == STYLE_ACTION) { 605 if (style_ == STYLE_ACTION) {
607 // When pressing space, the click event will be raised after the key is 606 // When pressing space, the click event will be raised after the key is
608 // released. 607 // released.
609 text_button_->SetState(Button::STATE_PRESSED); 608 text_button_->SetState(Button::STATE_PRESSED);
610 } else { 609 } else {
611 return false; 610 show_menu = true;
612 } 611 }
613 break; 612 break;
614 613
615 // Click the button only when the button style mode.
616 case ui::VKEY_RETURN: 614 case ui::VKEY_RETURN:
617 if (style_ != STYLE_ACTION) 615 if (style_ == STYLE_ACTION)
618 return false; 616 OnPerformAction();
619 OnPerformAction(); 617 else
618 show_menu = true;
620 break; 619 break;
621 620
622 default: 621 default:
623 return false; 622 return false;
624 } 623 }
625 624
626 if (show_menu) { 625 if (show_menu) {
627 ShowDropDownMenu(ui::MENU_SOURCE_KEYBOARD); 626 ShowDropDownMenu(ui::MENU_SOURCE_KEYBOARD);
628 } else if (new_index != selected_index_ && new_index != kNoSelection && 627 } else if (new_index != selected_index_ && new_index != kNoSelection &&
629 style_ != STYLE_ACTION) { 628 style_ != STYLE_ACTION) {
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
911 } 910 }
912 911
913 int Combobox::GetArrowContainerWidth() const { 912 int Combobox::GetArrowContainerWidth() const {
914 int padding = style_ == STYLE_NORMAL 913 int padding = style_ == STYLE_NORMAL
915 ? PlatformStyle::kComboboxNormalArrowPadding * 2 914 ? PlatformStyle::kComboboxNormalArrowPadding * 2
916 : kActionLeftPadding + kActionRightPadding; 915 : kActionLeftPadding + kActionRightPadding;
917 return ArrowSize().width() + padding; 916 return ArrowSize().width() + padding;
918 } 917 }
919 918
920 } // namespace views 919 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | ui/views/controls/combobox/combobox_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698