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

Side by Side Diff: views/controls/button/menu_button.cc

Issue 6685069: Disambiguate OnMouseCaptureLost from OnMouseReleased, etc. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments, fix tests, cleanup, etc. Created 9 years, 9 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 | « views/controls/button/menu_button.h ('k') | views/controls/button/radio_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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "views/controls/button/menu_button.h" 5 #include "views/controls/button/menu_button.h"
6 6
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "grit/app_strings.h" 8 #include "grit/app_strings.h"
9 #include "grit/app_resources.h" 9 #include "grit/app_resources.h"
10 #include "ui/base/accessibility/accessible_view_state.h" 10 #include "ui/base/accessibility/accessible_view_state.h"
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 TimeDelta delta = Time::Now() - menu_closed_time_; 191 TimeDelta delta = Time::Now() - menu_closed_time_;
192 int64 delta_in_milliseconds = delta.InMilliseconds(); 192 int64 delta_in_milliseconds = delta.InMilliseconds();
193 if (delta_in_milliseconds > kMinimumTimeBetweenButtonClicks) { 193 if (delta_in_milliseconds > kMinimumTimeBetweenButtonClicks) {
194 return Activate(); 194 return Activate();
195 } 195 }
196 } 196 }
197 } 197 }
198 return true; 198 return true;
199 } 199 }
200 200
201 void MenuButton::OnMouseReleased(const MouseEvent& event, bool canceled) { 201 void MenuButton::OnMouseReleased(const MouseEvent& event) {
202 // Explicitly test for left mouse button to show the menu. If we tested for 202 // Explicitly test for left mouse button to show the menu. If we tested for
203 // !IsTriggerableEvent it could lead to a situation where we end up showing 203 // !IsTriggerableEvent it could lead to a situation where we end up showing
204 // the menu and context menu (this would happen if the right button is not 204 // the menu and context menu (this would happen if the right button is not
205 // triggerable and there's a context menu). 205 // triggerable and there's a context menu).
206 if (GetDragOperations(event.location()) != ui::DragDropTypes::DRAG_NONE && 206 if (GetDragOperations(event.location()) != ui::DragDropTypes::DRAG_NONE &&
207 state() != BS_DISABLED && !canceled && !InDrag() && 207 state() != BS_DISABLED && !InDrag() && event.IsOnlyLeftMouseButton() &&
208 event.IsOnlyLeftMouseButton() && HitTest(event.location())) { 208 HitTest(event.location())) {
209 Activate(); 209 Activate();
210 } else { 210 } else {
211 TextButton::OnMouseReleased(event, canceled); 211 TextButton::OnMouseReleased(event);
212 } 212 }
213 } 213 }
214 214
215 // The reason we override View::OnMouseExited is because we get this event when 215 // The reason we override View::OnMouseExited is because we get this event when
216 // we display the menu. If we don't override this method then 216 // we display the menu. If we don't override this method then
217 // BaseButton::OnMouseExited will get the event and will set the button's state 217 // BaseButton::OnMouseExited will get the event and will set the button's state
218 // to BS_NORMAL instead of keeping the state BM_PUSHED. This, in turn, will 218 // to BS_NORMAL instead of keeping the state BM_PUSHED. This, in turn, will
219 // cause the button to appear depressed while the menu is displayed. 219 // cause the button to appear depressed while the menu is displayed.
220 void MenuButton::OnMouseExited(const MouseEvent& event) { 220 void MenuButton::OnMouseExited(const MouseEvent& event) {
221 if ((state_ != BS_DISABLED) && (!menu_visible_) && (!InDrag())) { 221 if ((state_ != BS_DISABLED) && (!menu_visible_) && (!InDrag())) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 NOTREACHED(); 259 NOTREACHED();
260 return 0; 260 return 0;
261 } 261 }
262 262
263 gfx::Rect monitor_bounds = 263 gfx::Rect monitor_bounds =
264 Screen::GetMonitorWorkAreaNearestWindow(GetWidget()->GetNativeView()); 264 Screen::GetMonitorWorkAreaNearestWindow(GetWidget()->GetNativeView());
265 return monitor_bounds.right() - 1; 265 return monitor_bounds.right() - 1;
266 } 266 }
267 267
268 } // namespace views 268 } // namespace views
OLDNEW
« no previous file with comments | « views/controls/button/menu_button.h ('k') | views/controls/button/radio_button.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698