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

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

Issue 10546104: Make IsTriggerableEvent take Event objects and use it to verify whether tap events should trigger. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Pass Event to ShouldEnterPushedState. Created 8 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « ui/views/controls/button/button_dropdown.h ('k') | ui/views/controls/button/custom_button.h » ('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/button_dropdown.h" 5 #include "ui/views/controls/button/button_dropdown.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 SetState(BS_HOT); 116 SetState(BS_HOT);
117 } 117 }
118 118
119 void ButtonDropDown::GetAccessibleState(ui::AccessibleViewState* state) { 119 void ButtonDropDown::GetAccessibleState(ui::AccessibleViewState* state) {
120 CustomButton::GetAccessibleState(state); 120 CustomButton::GetAccessibleState(state);
121 state->role = ui::AccessibilityTypes::ROLE_BUTTONDROPDOWN; 121 state->role = ui::AccessibilityTypes::ROLE_BUTTONDROPDOWN;
122 state->default_action = l10n_util::GetStringUTF16(IDS_APP_ACCACTION_PRESS); 122 state->default_action = l10n_util::GetStringUTF16(IDS_APP_ACCACTION_PRESS);
123 state->state = ui::AccessibilityTypes::STATE_HASPOPUP; 123 state->state = ui::AccessibilityTypes::STATE_HASPOPUP;
124 } 124 }
125 125
126 bool ButtonDropDown::ShouldEnterPushedState(const MouseEvent& event) { 126 bool ButtonDropDown::ShouldEnterPushedState(const Event& event) {
127 // Enter PUSHED state on press with Left or Right mouse button. Remain 127 // Enter PUSHED state on press with Left or Right mouse button or on taps.
128 // in this state while the context menu is open. 128 // Remain in this state while the context menu is open.
129 return ((ui::EF_LEFT_MOUSE_BUTTON | 129 return event.type() == ui::ET_GESTURE_TAP ||
130 ui::EF_RIGHT_MOUSE_BUTTON) & event.flags()) != 0; 130 event.type() == ui::ET_GESTURE_TAP_DOWN ||
131 (event.IsMouseEvent() && ((ui::EF_LEFT_MOUSE_BUTTON |
132 ui::EF_RIGHT_MOUSE_BUTTON) & event.flags()) != 0);
131 } 133 }
132 134
133 void ButtonDropDown::ShowDropDownMenu(gfx::NativeView window) { 135 void ButtonDropDown::ShowDropDownMenu(gfx::NativeView window) {
134 gfx::Rect lb = GetLocalBounds(); 136 gfx::Rect lb = GetLocalBounds();
135 137
136 // Both the menu position and the menu anchor type change if the UI layout 138 // Both the menu position and the menu anchor type change if the UI layout
137 // is right-to-left. 139 // is right-to-left.
138 gfx::Point menu_position(lb.origin()); 140 gfx::Point menu_position(lb.origin());
139 menu_position.Offset(0, lb.height() - 1); 141 menu_position.Offset(0, lb.height() - 1);
140 if (base::i18n::IsRTL()) 142 if (base::i18n::IsRTL())
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 SetState(BS_NORMAL); 187 SetState(BS_NORMAL);
186 } 188 }
187 189
188 //////////////////////////////////////////////////////////////////////////////// 190 ////////////////////////////////////////////////////////////////////////////////
189 // 191 //
190 // ButtonDropDown - Accessibility 192 // ButtonDropDown - Accessibility
191 // 193 //
192 //////////////////////////////////////////////////////////////////////////////// 194 ////////////////////////////////////////////////////////////////////////////////
193 195
194 } // namespace views 196 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/button/button_dropdown.h ('k') | ui/views/controls/button/custom_button.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698