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

Unified Diff: chrome/browser/cocoa/menu_tracked_button.h

Issue 3137013: [Mac] Implement highlight-on-hover for the Wrench menu buttons. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Created 10 years, 4 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
Index: chrome/browser/cocoa/menu_tracked_button.h
diff --git a/chrome/browser/cocoa/menu_tracked_button.h b/chrome/browser/cocoa/menu_tracked_button.h
index df42255fd9b94c828ed900f267feb30732c281ce..00dc78abe70287569cf1e56e9ba0934a825d83b8 100644
--- a/chrome/browser/cocoa/menu_tracked_button.h
+++ b/chrome/browser/cocoa/menu_tracked_button.h
@@ -12,6 +12,15 @@
// the custom view of an NSMenuItem. If the user opens the menu in a non-sticky
// fashion (i.e. clicks, holds, and drags) and then releases the mouse over
// a MenuTrackedButton, it will |-performClick:| itself.
+//
+// To create the hover state effects, there are two code paths. When the menu
+// is opened sticky, a tracking rect produces mouse entered/exit events that
+// allow for setting the cell's highlight property. When in a drag cycle,
+// however, the only event received is |-mouseDragged:|. Therefore, a
+// delayed selector is scheduled to poll the mouse location after each drag
+// event. This checks if the user is still over the button after the drag
+// events stop being sent, indicating either the user is hovering without
+// movement or that the mouse is no longer over the receiver.
@interface MenuTrackedButton : NSButton {
@private
// If the button received a |-mouseEntered:| event. This short-circuits the
@@ -21,6 +30,10 @@
// Whether or not the user is in a click-drag-release event sequence. If so
// and this receives a |-mouseUp:|, then this will click itself.
BOOL tracking_;
+
+ // In order to get hover effects when the menu is sticky-opened, a tracking
+ // rect needs to be installed on the button.
+ NSTrackingRectTag trackingTag_;
}
@end
« no previous file with comments | « no previous file | chrome/browser/cocoa/menu_tracked_button.mm » ('j') | chrome/browser/cocoa/menu_tracked_button.mm » ('J')

Powered by Google App Engine
This is Rietveld 408576698