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

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

Issue 1898633004: Views: Add new SetFocusBehavior method. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 4 years, 8 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
« no previous file with comments | « ui/views/controls/webview/webview_unittest.cc ('k') | ui/views/examples/tree_view_example.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/examples/button_example.cc
diff --git a/ui/views/examples/button_example.cc b/ui/views/examples/button_example.cc
index 02a56822c6540ef8340ffaa2d58d89608b55c496..00ca3fecd6b26699db3e5c253d479f13e1c9344e 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_->SetFocusable(true);
+ label_button_->SetFocusBehavior(View::FocusBehavior::ALWAYS);
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_->SetFocusable(true);
+ image_button_->SetFocusBehavior(View::FocusBehavior::ALWAYS);
image_button_->SetImage(ImageButton::STATE_NORMAL,
rb.GetImageNamed(IDR_CLOSE).ToImageSkia());
image_button_->SetImage(ImageButton::STATE_HOVERED,
@@ -103,7 +103,9 @@ void ButtonExample::LabelButtonPressed(LabelButton* label_button,
}
} else if (event.IsShiftDown()) {
if (event.IsAltDown()) {
- label_button->SetFocusable(!label_button->IsFocusable());
+ label_button->SetFocusBehavior(label_button->IsFocusable()
+ ? View::FocusBehavior::NEVER
+ : View::FocusBehavior::ALWAYS);
} else {
label_button->SetStyle(static_cast<Button::ButtonStyle>(
(label_button->style() + 1) % Button::STYLE_COUNT));
« no previous file with comments | « ui/views/controls/webview/webview_unittest.cc ('k') | ui/views/examples/tree_view_example.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698