Chromium Code Reviews| 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 |