Commit 60e91436 authored by tapted@chromium.org's avatar tapted@chromium.org

Squelch context menus on the OSX App List when both buttons are pressed.

The apps grid uses [NSView menuForEvent:..] for its menus, so needs to
check the button state explicitly to match the behaviour of [NSButton
menu] (which isn't used, e.g., because the NSButton doesn't fill the
grid cell).

This CL adds a check to suppress the menu when the button is in the
"lit" state, which occurs when the button is being held down.

BUG=328835
TEST=Hold the left, then the right, mouse buttons over a app launcher
item. A menu shouldn't appear. Releasing the left button (without moving
the mouse cursor) will launch the item.

Review URL: https://codereview.chromium.org/93793012

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@243391 0039d316-1c4b-4281-b951-d872f2087c98
parent a0e7e866
...@@ -983,6 +983,13 @@ TEST_F(AppsGridControllerTest, ContextMenus) { ...@@ -983,6 +983,13 @@ TEST_F(AppsGridControllerTest, ContextMenus) {
menu = [page menuForEvent:mouse_at_cell_1]; menu = [page menuForEvent:mouse_at_cell_1];
EXPECT_EQ(1, [menu numberOfItems]); EXPECT_EQ(1, [menu numberOfItems]);
EXPECT_NSEQ(@"Menu For: Item Two", [[menu itemAtIndex:0] title]); EXPECT_NSEQ(@"Menu For: Item Two", [[menu itemAtIndex:0] title]);
// Test that a button being held down with the left button does not also show
// a context menu.
[GetItemViewAt(0) highlight:YES];
EXPECT_FALSE([page menuForEvent:mouse_at_cell_0]);
[GetItemViewAt(0) highlight:NO];
EXPECT_TRUE([page menuForEvent:mouse_at_cell_0]);
} }
} // namespace test } // namespace test
......
...@@ -345,6 +345,10 @@ void ItemModelObserverBridge::ItemPercentDownloadedChanged() { ...@@ -345,6 +345,10 @@ void ItemModelObserverBridge::ItemPercentDownloadedChanged() {
} }
- (NSMenu*)contextMenu { - (NSMenu*)contextMenu {
// Don't show the menu if button is already held down, e.g. with a left-click.
if ([[[self button] cell] isHighlighted])
return nil;
[self setSelected:YES]; [self setSelected:YES];
return observerBridge_->GetContextMenu(); return observerBridge_->GetContextMenu();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment