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

Side by Side Diff: ui/views/controls/button/custom_button.cc

Issue 1645013004: Views - dialog button defaultness shouldn't follow focus. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix win compile 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 unified diff | Download patch
« no previous file with comments | « ui/views/controls/button/custom_button.h ('k') | ui/views/controls/button/label_button.cc » ('j') | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/views/controls/button/custom_button.h" 5 #include "ui/views/controls/button/custom_button.h"
6 6
7 #include "ui/accessibility/ax_view_state.h" 7 #include "ui/accessibility/ax_view_state.h"
8 #include "ui/events/event.h" 8 #include "ui/events/event.h"
9 #include "ui/events/event_utils.h" 9 #include "ui/events/event_utils.h"
10 #include "ui/events/keycodes/keyboard_codes.h" 10 #include "ui/events/keycodes/keyboard_codes.h"
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 } 275 }
276 SetState(STATE_NORMAL); 276 SetState(STATE_NORMAL);
277 // TODO(beng): remove once NotifyClick takes ui::Event. 277 // TODO(beng): remove once NotifyClick takes ui::Event.
278 ui::MouseEvent synthetic_event( 278 ui::MouseEvent synthetic_event(
279 ui::ET_MOUSE_RELEASED, gfx::Point(), gfx::Point(), ui::EventTimeForNow(), 279 ui::ET_MOUSE_RELEASED, gfx::Point(), gfx::Point(), ui::EventTimeForNow(),
280 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); 280 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON);
281 NotifyClick(synthetic_event); 281 NotifyClick(synthetic_event);
282 return true; 282 return true;
283 } 283 }
284 284
285 bool CustomButton::SkipDefaultKeyEventProcessing(const ui::KeyEvent& event) {
286 // If this button is focused and the user presses space or enter, don't let
287 // that be treated as an accelerator.
288 return (event.key_code() == ui::VKEY_SPACE) ||
289 (event.key_code() == ui::VKEY_RETURN);
290 }
291
285 void CustomButton::ShowContextMenu(const gfx::Point& p, 292 void CustomButton::ShowContextMenu(const gfx::Point& p,
286 ui::MenuSourceType source_type) { 293 ui::MenuSourceType source_type) {
287 if (!context_menu_controller()) 294 if (!context_menu_controller())
288 return; 295 return;
289 296
290 // We're about to show the context menu. Showing the context menu likely means 297 // We're about to show the context menu. Showing the context menu likely means
291 // we won't get a mouse exited and reset state. Reset it now to be sure. 298 // we won't get a mouse exited and reset state. Reset it now to be sure.
292 if (state_ != STATE_DISABLED) 299 if (state_ != STATE_DISABLED)
293 SetState(STATE_NORMAL); 300 SetState(STATE_NORMAL);
294 View::ShowContextMenu(p, source_type); 301 View::ShowContextMenu(p, source_type);
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 return GetWidget() && GetWidget()->GetTopLevelWidget() != GetWidget(); 463 return GetWidget() && GetWidget()->GetTopLevelWidget() != GetWidget();
457 } 464 }
458 465
459 bool CustomButton::FocusInChildWidget() const { 466 bool CustomButton::FocusInChildWidget() const {
460 return GetWidget() && 467 return GetWidget() &&
461 GetWidget()->GetRootView()->Contains( 468 GetWidget()->GetRootView()->Contains(
462 GetFocusManager()->GetFocusedView()); 469 GetFocusManager()->GetFocusedView());
463 } 470 }
464 471
465 } // namespace views 472 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/button/custom_button.h ('k') | ui/views/controls/button/label_button.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698