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

Unified Diff: ui/views/examples/button_example.cc

Issue 1894383002: MacViews: Implement Full Keyboard Access. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@SetFocusBehavior
Patch Set: Rebased Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: ui/views/examples/button_example.cc
diff --git a/ui/views/examples/button_example.cc b/ui/views/examples/button_example.cc
index 00ca3fecd6b26699db3e5c253d479f13e1c9344e..b8a8047486eca4c366d8545ced6073c3c642c7ab 100644
--- a/ui/views/examples/button_example.cc
+++ b/ui/views/examples/button_example.cc
@@ -44,7 +44,7 @@ void ButtonExample::CreateExampleView(View* container) {
container->SetLayoutManager(layout);
label_button_ = new LabelButton(this, ASCIIToUTF16(kLabelButton));
- label_button_->SetFocusBehavior(View::FocusBehavior::ALWAYS);
+ Button::ConfigureDefaultFocus(label_button_);
container->AddChildView(label_button_);
styled_button_ = new LabelButton(this, ASCIIToUTF16("Styled Button"));
@@ -71,7 +71,7 @@ void ButtonExample::CreateExampleView(View* container) {
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
image_button_ = new ImageButton(this);
- image_button_->SetFocusBehavior(View::FocusBehavior::ALWAYS);
+ Button::ConfigureDefaultFocus(image_button_);
image_button_->SetImage(ImageButton::STATE_NORMAL,
rb.GetImageNamed(IDR_CLOSE).ToImageSkia());
image_button_->SetImage(ImageButton::STATE_HOVERED,
@@ -103,9 +103,10 @@ void ButtonExample::LabelButtonPressed(LabelButton* label_button,
}
} else if (event.IsShiftDown()) {
if (event.IsAltDown()) {
- label_button->SetFocusBehavior(label_button->IsFocusable()
- ? View::FocusBehavior::NEVER
- : View::FocusBehavior::ALWAYS);
+ // Toggle focusability.
+ label_button_->IsAccessibilityFocusable()
+ ? label_button_->SetFocusBehavior(View::FocusBehavior::NEVER)
+ : Button::ConfigureDefaultFocus(label_button_);
} else {
label_button->SetStyle(static_cast<Button::ButtonStyle>(
(label_button->style() + 1) % Button::STYLE_COUNT));

Powered by Google App Engine
This is Rietveld 408576698