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

Unified Diff: ui/webui/resources/js/cr/ui/menu_button.js

Issue 1358893003: Ignore mouseup shortly after showing cr.ui.Menu (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 years, 3 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
« ui/webui/resources/js/cr/ui/menu.js ('K') | « ui/webui/resources/js/cr/ui/menu.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/webui/resources/js/cr/ui/menu_button.js
diff --git a/ui/webui/resources/js/cr/ui/menu_button.js b/ui/webui/resources/js/cr/ui/menu_button.js
index f499f5c20b0445d6283774eae8f442d3f93e8ac5..3a7bae5fc7897f71693d938c465f66fbbe4299f7 100644
--- a/ui/webui/resources/js/cr/ui/menu_button.js
+++ b/ui/webui/resources/js/cr/ui/menu_button.js
@@ -110,7 +110,7 @@ cr.define('cr.ui', function() {
this.hideMenu();
} else if (e.button == 0) { // Only show the menu when using left
// mouse button.
- this.showMenu(false);
+ this.showMenu(false, {x: e.screenX, y: e.screenY});
// Prevent the button from stealing focus on mousedown.
e.preventDefault();
@@ -158,7 +158,7 @@ cr.define('cr.ui', function() {
case 'contextmenu':
if ((!this.menu || !this.menu.contains(e.target)) &&
(!this.hideTimestamp_ || Date.now() - this.hideTimestamp_ > 50))
- this.showMenu(true);
+ this.showMenu(true, {x: e.screenX, y: e.screenY});
e.preventDefault();
// Don't allow elements further up in the DOM to show their menus.
e.stopPropagation();
@@ -175,8 +175,10 @@ cr.define('cr.ui', function() {
* Shows the menu.
* @param {boolean} shouldSetFocus Whether to set focus on the
* selected menu item.
+ * @param {{x: number, y: number}=} opt_mousePos The position of the mouse
+ * when shown (in screen coordinates).
*/
- showMenu: function(shouldSetFocus) {
+ showMenu: function(shouldSetFocus, opt_mousePos) {
this.hideMenu();
this.menu.updateCommands(this);
@@ -189,7 +191,7 @@ cr.define('cr.ui', function() {
if (!this.dispatchEvent(event))
return;
- this.menu.hidden = false;
+ this.menu.show(opt_mousePos);
this.setAttribute('menu-shown', '');
@@ -225,7 +227,7 @@ cr.define('cr.ui', function() {
this.menu.classList.add('hide-delayed');
else
this.menu.classList.remove('hide-delayed');
- this.menu.hidden = true;
+ this.menu.hide();
this.showingEvents_.removeAll();
this.focus();
« ui/webui/resources/js/cr/ui/menu.js ('K') | « ui/webui/resources/js/cr/ui/menu.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698