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

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

Issue 101573006: Changes MouseEvent constructor to take changed_button_flags. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix test; needs updated expectations as mouse entered wasnt sent before because of env::mouse_butto… Created 7 years 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
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/base/accessibility/accessible_view_state.h" 7 #include "ui/base/accessibility/accessible_view_state.h"
8 #include "ui/events/event.h" 8 #include "ui/events/event.h"
9 #include "ui/events/keycodes/keyboard_codes.h" 9 #include "ui/events/keycodes/keyboard_codes.h"
10 #include "ui/gfx/animation/throb_animation.h" 10 #include "ui/gfx/animation/throb_animation.h"
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 // the Windows native behavior of buttons, where Space clicks the button on 192 // the Windows native behavior of buttons, where Space clicks the button on
193 // KeyRelease and Enter clicks the button on KeyPressed. 193 // KeyRelease and Enter clicks the button on KeyPressed.
194 if (event.key_code() == ui::VKEY_SPACE) { 194 if (event.key_code() == ui::VKEY_SPACE) {
195 SetState(STATE_PRESSED); 195 SetState(STATE_PRESSED);
196 } else if (event.key_code() == ui::VKEY_RETURN) { 196 } else if (event.key_code() == ui::VKEY_RETURN) {
197 SetState(STATE_NORMAL); 197 SetState(STATE_NORMAL);
198 // TODO(beng): remove once NotifyClick takes ui::Event. 198 // TODO(beng): remove once NotifyClick takes ui::Event.
199 ui::MouseEvent synthetic_event(ui::ET_MOUSE_RELEASED, 199 ui::MouseEvent synthetic_event(ui::ET_MOUSE_RELEASED,
200 gfx::Point(), 200 gfx::Point(),
201 gfx::Point(), 201 gfx::Point(),
202 ui::EF_LEFT_MOUSE_BUTTON,
202 ui::EF_LEFT_MOUSE_BUTTON); 203 ui::EF_LEFT_MOUSE_BUTTON);
203 NotifyClick(synthetic_event); 204 NotifyClick(synthetic_event);
204 } else { 205 } else {
205 return false; 206 return false;
206 } 207 }
207 return true; 208 return true;
208 } 209 }
209 210
210 bool CustomButton::OnKeyReleased(const ui::KeyEvent& event) { 211 bool CustomButton::OnKeyReleased(const ui::KeyEvent& event) {
211 if ((state_ == STATE_DISABLED) || (event.key_code() != ui::VKEY_SPACE)) 212 if ((state_ == STATE_DISABLED) || (event.key_code() != ui::VKEY_SPACE))
212 return false; 213 return false;
213 214
214 SetState(STATE_NORMAL); 215 SetState(STATE_NORMAL);
215 // TODO(beng): remove once NotifyClick takes ui::Event. 216 // TODO(beng): remove once NotifyClick takes ui::Event.
216 ui::MouseEvent synthetic_event(ui::ET_MOUSE_RELEASED, 217 ui::MouseEvent synthetic_event(ui::ET_MOUSE_RELEASED,
217 gfx::Point(), 218 gfx::Point(),
218 gfx::Point(), 219 gfx::Point(),
220 ui::EF_LEFT_MOUSE_BUTTON,
219 ui::EF_LEFT_MOUSE_BUTTON); 221 ui::EF_LEFT_MOUSE_BUTTON);
220 NotifyClick(synthetic_event); 222 NotifyClick(synthetic_event);
221 return true; 223 return true;
222 } 224 }
223 225
224 void CustomButton::OnGestureEvent(ui::GestureEvent* event) { 226 void CustomButton::OnGestureEvent(ui::GestureEvent* event) {
225 if (state_ == STATE_DISABLED) { 227 if (state_ == STATE_DISABLED) {
226 Button::OnGestureEvent(event); 228 Button::OnGestureEvent(event);
227 return; 229 return;
228 } 230 }
(...skipping 24 matching lines...) Expand all
253 bool CustomButton::AcceleratorPressed(const ui::Accelerator& accelerator) { 255 bool CustomButton::AcceleratorPressed(const ui::Accelerator& accelerator) {
254 SetState(STATE_NORMAL); 256 SetState(STATE_NORMAL);
255 /* 257 /*
256 ui::KeyEvent key_event(ui::ET_KEY_RELEASED, accelerator.key_code(), 258 ui::KeyEvent key_event(ui::ET_KEY_RELEASED, accelerator.key_code(),
257 accelerator.modifiers()); 259 accelerator.modifiers());
258 */ 260 */
259 // TODO(beng): remove once NotifyClick takes ui::Event. 261 // TODO(beng): remove once NotifyClick takes ui::Event.
260 ui::MouseEvent synthetic_event(ui::ET_MOUSE_RELEASED, 262 ui::MouseEvent synthetic_event(ui::ET_MOUSE_RELEASED,
261 gfx::Point(), 263 gfx::Point(),
262 gfx::Point(), 264 gfx::Point(),
265 ui::EF_LEFT_MOUSE_BUTTON,
263 ui::EF_LEFT_MOUSE_BUTTON); 266 ui::EF_LEFT_MOUSE_BUTTON);
264 NotifyClick(synthetic_event); 267 NotifyClick(synthetic_event);
265 return true; 268 return true;
266 } 269 }
267 270
268 void CustomButton::ShowContextMenu(const gfx::Point& p, 271 void CustomButton::ShowContextMenu(const gfx::Point& p,
269 ui::MenuSourceType source_type) { 272 ui::MenuSourceType source_type) {
270 if (!context_menu_controller()) 273 if (!context_menu_controller())
271 return; 274 return;
272 275
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 if (!details.is_add && state_ != STATE_DISABLED) 352 if (!details.is_add && state_ != STATE_DISABLED)
350 SetState(STATE_NORMAL); 353 SetState(STATE_NORMAL);
351 } 354 }
352 355
353 void CustomButton::OnBlur() { 356 void CustomButton::OnBlur() {
354 if (IsHotTracked()) 357 if (IsHotTracked())
355 SetState(STATE_NORMAL); 358 SetState(STATE_NORMAL);
356 } 359 }
357 360
358 } // namespace views 361 } // namespace views
OLDNEW
« no previous file with comments | « ui/message_center/views/notifier_settings_view.cc ('k') | ui/views/controls/button/custom_button_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698