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

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: Rebased 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
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..798e2f1042ea3fc4ce8b1f15ec3ddee13d6a0752 100644
--- a/ui/views/window/dialog_client_view.cc
+++ b/ui/views/window/dialog_client_view.cc
@@ -80,15 +80,14 @@ void DialogClientView::CancelWindow() {
}
}
-void DialogClientView::UpdateDialogButtons() {
+void DialogClientView::UpdateOKButton() {
const int buttons = GetDialogDelegate()->GetDialogButtons();
- ui::Accelerator escape(ui::VKEY_ESCAPE, ui::EF_NONE);
-
if (buttons & ui::DIALOG_BUTTON_OK) {
if (!ok_button_) {
ok_button_ = CreateDialogButton(ui::DIALOG_BUTTON_OK);
if (!(buttons & ui::DIALOG_BUTTON_CANCEL))
- ok_button_->AddAccelerator(escape);
+ ok_button_->AddAccelerator(
+ ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE));
AddChildView(ok_button_);
}
@@ -97,11 +96,14 @@ void DialogClientView::UpdateDialogButtons() {
delete ok_button_;
ok_button_ = NULL;
}
+}
- if (buttons & ui::DIALOG_BUTTON_CANCEL) {
+void DialogClientView::UpdateCancelButton() {
+ if (GetDialogDelegate()->GetDialogButtons() & ui::DIALOG_BUTTON_CANCEL) {
if (!cancel_button_) {
cancel_button_ = CreateDialogButton(ui::DIALOG_BUTTON_CANCEL);
- cancel_button_->AddAccelerator(escape);
+ cancel_button_->AddAccelerator(
+ ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE));
AddChildView(cancel_button_);
}
@@ -110,10 +112,22 @@ void DialogClientView::UpdateDialogButtons() {
delete cancel_button_;
cancel_button_ = NULL;
}
+}
+
+void DialogClientView::UpdateDialogButtons() {
+ // Add buttons in left to right order, so that they focus order is left to
tapted 2016/02/15 06:24:14 nit: they -> the is left to right -> matches
karandeepb 2016/02/15 06:59:15 Done.
tapted 2016/02/15 10:22:20 (I think you missed the second line of this nit :)
karandeepb 2016/02/15 23:29:33 Done.
+ // right.
+ if (kIsOkButtonOnLeftSide) {
+ UpdateOKButton();
+ UpdateCancelButton();
+ } else {
+ UpdateCancelButton();
+ UpdateOKButton();
+ }
// Use the escape key to close the window if there are no dialog buttons.
if (!has_dialog_buttons())
- AddAccelerator(escape);
+ AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE));
else
ResetAccelerators();
}
@@ -247,8 +261,8 @@ void DialogClientView::ViewHierarchyChanged(
const ViewHierarchyChangedDetails& details) {
ClientView::ViewHierarchyChanged(details);
if (details.is_add && details.child == this) {
- UpdateDialogButtons();
CreateExtraView();
+ UpdateDialogButtons();
CreateFootnoteView();
} else if (!details.is_add && details.child != this) {
if (details.child == ok_button_)
« ui/views/window/dialog_client_view.h ('K') | « ui/views/window/dialog_client_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698