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

Unified Diff: ui/views/window/dialog_client_view.cc

Issue 1690133003: DialogClientView: Correct the order in which subviews are focused. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review comments. Add tests. Created 4 years, 10 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/window/dialog_client_view.h ('k') | ui/views/window/dialog_client_view_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/window/dialog_client_view.cc
diff --git a/ui/views/window/dialog_client_view.cc b/ui/views/window/dialog_client_view.cc
index 569944542f94a7623b6c4c9f96f84cc393728a72..8649d2c8b236992b4195da24dc74bcf28c33629f 100644
--- a/ui/views/window/dialog_client_view.cc
+++ b/ui/views/window/dialog_client_view.cc
@@ -256,6 +256,8 @@ void DialogClientView::ViewHierarchyChanged(
if (details.child == cancel_button_)
cancel_button_ = NULL;
}
+
+ SetupFocusChain();
}
void DialogClientView::OnNativeThemeChanged(const ui::NativeTheme* theme) {
@@ -380,4 +382,32 @@ void DialogClientView::Close() {
GetDialogDelegate()->OnClosed();
}
+void DialogClientView::SetupFocusChain() {
+ // Create a vector of child views in the order of intended focus.
+ std::vector<View*> child_views;
+ child_views.push_back(contents_view());
+ child_views.push_back(extra_view_);
+ if (kIsOkButtonOnLeftSide) {
+ child_views.push_back(ok_button_);
+ child_views.push_back(cancel_button_);
+ } else {
+ child_views.push_back(cancel_button_);
+ child_views.push_back(ok_button_);
+ }
+ child_views.push_back(footnote_view_);
+
+ // Remove all null views from the vector.
+ child_views.erase(
+ std::remove(child_views.begin(), child_views.end(), nullptr),
+ child_views.end());
+
+ // Add a dummy null view, so that the last view has null as the next focusable
+ // view.
+ child_views.push_back(nullptr);
sky 2016/02/17 18:18:26 I actually prefer you don't do this. Otherwise we
karandeepb 2016/02/18 01:44:59 Done.
+
+ // Setup focus.
+ for (size_t i = 0; i < child_views.size() - 1; i++)
+ child_views[i]->SetNextFocusableView(child_views[i + 1]);
+}
+
} // namespace views
« no previous file with comments | « ui/views/window/dialog_client_view.h ('k') | ui/views/window/dialog_client_view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698