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

Side by Side Diff: chrome/views/message_box_view.cc

Issue 8786: Fix default focused button in dialogs (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/views/message_box_view.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/views/message_box_view.h" 5 #include "chrome/views/message_box_view.h"
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "chrome/browser/controller.h" 9 #include "chrome/browser/controller.h"
10 #include "chrome/browser/views/standard_layout.h" 10 #include "chrome/browser/views/standard_layout.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 73
74 /////////////////////////////////////////////////////////////////////////////// 74 ///////////////////////////////////////////////////////////////////////////////
75 // MessageBoxView, views::View overrides: 75 // MessageBoxView, views::View overrides:
76 76
77 void MessageBoxView::ViewHierarchyChanged(bool is_add, 77 void MessageBoxView::ViewHierarchyChanged(bool is_add,
78 views::View* parent, 78 views::View* parent,
79 views::View* child) { 79 views::View* child) {
80 if (child == this && is_add) { 80 if (child == this && is_add) {
81 if (prompt_field_) 81 if (prompt_field_)
82 prompt_field_->SelectAll(); 82 prompt_field_->SelectAll();
83 MessageLoop::current()->PostTask(FROM_HERE,
84 focus_grabber_factory_.NewRunnableMethod(
85 &MessageBoxView::FocusFirstFocusableControl));
86 } 83 }
87 } 84 }
88 85
89 /////////////////////////////////////////////////////////////////////////////// 86 ///////////////////////////////////////////////////////////////////////////////
90 // MessageBoxView, private: 87 // MessageBoxView, private:
91 88
92 void MessageBoxView::FocusFirstFocusableControl() {
93 if (prompt_field_)
94 prompt_field_->RequestFocus();
95 else if (check_box_)
96 check_box_->RequestFocus();
97 else
98 RequestFocus();
99 }
100
101 void MessageBoxView::Init(int dialog_flags, 89 void MessageBoxView::Init(int dialog_flags,
102 const std::wstring& default_prompt) { 90 const std::wstring& default_prompt) {
103 message_label_->SetMultiLine(true); 91 message_label_->SetMultiLine(true);
104 message_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); 92 message_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
105 93
106 if (dialog_flags & kFlagHasPromptField) { 94 if (dialog_flags & kFlagHasPromptField) {
107 prompt_field_ = new views::TextField; 95 prompt_field_ = new views::TextField;
108 prompt_field_->SetText(default_prompt); 96 prompt_field_->SetText(default_prompt);
109 } 97 }
110 98
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 162
175 if (check_box_) { 163 if (check_box_) {
176 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); 164 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
177 layout->StartRow(0, checkbox_column_view_set_id); 165 layout->StartRow(0, checkbox_column_view_set_id);
178 layout->AddView(check_box_); 166 layout->AddView(check_box_);
179 } 167 }
180 168
181 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); 169 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
182 } 170 }
183 171
OLDNEW
« no previous file with comments | « chrome/views/message_box_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698