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

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. 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..f6567a290acced9eca464dded26de5d10b45b2bc 100644
--- a/ui/views/window/dialog_client_view.cc
+++ b/ui/views/window/dialog_client_view.cc
@@ -252,10 +252,16 @@ void DialogClientView::ViewHierarchyChanged(
CreateFootnoteView();
} else if (!details.is_add && details.child != this) {
if (details.child == ok_button_)
- ok_button_ = NULL;
- if (details.child == cancel_button_)
- cancel_button_ = NULL;
+ ok_button_ = nullptr;
+ else if (details.child == cancel_button_)
+ cancel_button_ = nullptr;
+ else if (details.child == extra_view_)
+ extra_view_ = nullptr;
+ else if (details.child == footnote_view_)
+ footnote_view_ = nullptr;
}
+
+ SetupFocusChain();
}
void DialogClientView::OnNativeThemeChanged(const ui::NativeTheme* theme) {
@@ -380,4 +386,30 @@ 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());
+
+ // Setup focus.
+ for (size_t i = 0; i < child_views.size(); i++) {
+ child_views[i]->SetNextFocusableView(
+ i + 1 != child_views.size() ? child_views[i + 1] : nullptr);
+ }
+}
+
} // 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