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

Unified Diff: ui/views/view.cc

Issue 12395010: Context menu on views must show on mouse dpwn for non-WIN. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: patch Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/view.cc
diff --git a/ui/views/view.cc b/ui/views/view.cc
index 98e3b44b210a9652d9abf9a81f277fa4edd7421d..d012843bb7f75caa9685674bc50ab6f6ff327a6b 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)
+bool context_menu_on_mouse_press = false;
sadrul 2013/03/05 16:30:11 this value never changes, right? It should be 'con
varunjain 2013/03/05 21:14:21 Done.
+#else
+bool context_menu_on_mouse_press = true;
+#endif
+
// Saves the drawing state, and restores the state when going out of scope.
class ScopedCanvas {
public:
@@ -2040,8 +2046,23 @@ bool View::ProcessMousePressed(const ui::MouseEvent& event) {
context_menu_controller_ : 0;
const bool enabled = enabled_;
- const bool result = OnMousePressed(event);
- // WARNING: we may have been deleted, don't use any View variables.
+
+ bool result = false;
+ if (enabled_ && context_menu_controller_ && event.IsOnlyRightMouseButton() &&
+ context_menu_on_mouse_press) {
+ // Assume that if there is a context menu controller we won't be deleted
+ // from mouse pressed.
+ gfx::Point location(event.location());
+ result = OnMousePressed(event);
+ if (HitTestPoint(location)) {
+ ConvertPointToScreen(this, &location);
+ ShowContextMenu(location, true);
+ return true;
+ }
+ } else {
+ result = OnMousePressed(event);
+ // WARNING: we may have been deleted, don't use any View variables.
+ }
if (!enabled)
return result;
@@ -2076,7 +2097,8 @@ bool View::ProcessMouseDragged(const ui::MouseEvent& event) {
}
void View::ProcessMouseReleased(const ui::MouseEvent& event) {
- if (context_menu_controller_ && event.IsOnlyRightMouseButton()) {
+ if (!context_menu_on_mouse_press && 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());
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698