Chromium Code Reviews| Index: ui/views/view.cc |
| diff --git a/ui/views/view.cc b/ui/views/view.cc |
| index e014e0a98f35ba719226c408bec54f03f73c7673..4bb6dbfbf6bd5ed0ef38a2c5028e79eb94c4045f 100644 |
| --- a/ui/views/view.cc |
| +++ b/ui/views/view.cc |
| @@ -57,6 +57,12 @@ bool use_acceleration_when_possible = true; |
| bool use_acceleration_when_possible = false; |
| #endif |
| +#if defined(OS_WIN) |
| +const bool kContextMenuOnMousePress = false; |
| +#else |
| +const bool kContextMenuOnMousePress = true; |
| +#endif |
| + |
| // Saves the drawing state, and restores the state when going out of scope. |
| class ScopedCanvas { |
| public: |
| @@ -2062,6 +2068,7 @@ bool View::ProcessMousePressed(const ui::MouseEvent& event) { |
| GetDragOperations(event.location()) : 0; |
| ContextMenuController* context_menu_controller = event.IsRightMouseButton() ? |
| context_menu_controller_ : 0; |
| + View::DragInfo* drag_info = GetDragInfo(); |
| const bool enabled = enabled_; |
| const bool result = OnMousePressed(event); |
| @@ -2070,8 +2077,20 @@ bool View::ProcessMousePressed(const ui::MouseEvent& event) { |
| if (!enabled) |
| return result; |
| + // Assume that if there is a context menu controller we won't be deleted |
|
sky
2013/03/20 21:35:53
Hm. Don't you see the warning on 2075? I don't see
varunjain
2013/03/20 22:05:52
This seemed standard because the same assumption i
|
| + // from mouse pressed. |
| + if (event.IsOnlyRightMouseButton() && context_menu_controller && |
| + kContextMenuOnMousePress) { |
| + gfx::Point location(event.location()); |
| + if (HitTestPoint(location)) { |
| + ConvertPointToScreen(this, &location); |
| + ShowContextMenu(location, true); |
| + return true; |
| + } |
| + } |
| + |
| if (drag_operations != ui::DragDropTypes::DRAG_NONE) { |
| - GetDragInfo()->PossibleDrag(event.location()); |
| + drag_info->PossibleDrag(event.location()); |
| return true; |
| } |
| return !!context_menu_controller || result; |
| @@ -2100,7 +2119,8 @@ bool View::ProcessMouseDragged(const ui::MouseEvent& event) { |
| } |
| void View::ProcessMouseReleased(const ui::MouseEvent& event) { |
| - if (context_menu_controller_ && event.IsOnlyRightMouseButton()) { |
| + if (!kContextMenuOnMousePress && context_menu_controller_ && |
| + event.IsOnlyRightMouseButton()) { |
| // Assume that if there is a context menu controller we won't be deleted |
| // from mouse released. |
| gfx::Point location(event.location()); |