Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / wrench_menu / menu_tracked_button.h
blob528d8b807105f292df9cd33e0c23f394211d7fc1
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_COCOA_WRENCH_MENU_MENU_TRACKED_BUTTON_H_
6 #define CHROME_BROWSER_UI_COCOA_WRENCH_MENU_MENU_TRACKED_BUTTON_H_
8 #import <Cocoa/Cocoa.h>
10 // A MenuTrackedButton is meant to be used whenever a button is placed inside
11 // the custom view of an NSMenuItem. If the user opens the menu in a non-sticky
12 // fashion (i.e. clicks, holds, and drags) and then releases the mouse over
13 // a MenuTrackedButton, it will |-performClick:| itself.
15 // To create the hover state effects, there are two code paths. When the menu
16 // is opened sticky, a tracking rect produces mouse entered/exit events that
17 // allow for setting the cell's highlight property. When in a drag cycle,
18 // however, the only event received is |-mouseDragged:|. Therefore, a
19 // delayed selector is scheduled to poll the mouse location after each drag
20 // event. This checks if the user is still over the button after the drag
21 // events stop being sent, indicating either the user is hovering without
22 // movement or that the mouse is no longer over the receiver.
23 @interface MenuTrackedButton : NSButton {
24 @private
25 // If the button received a |-mouseEntered:| event. This short-circuits the
26 // custom drag tracking logic.
27 BOOL didEnter_;
29 // Whether or not the user is in a click-drag-release event sequence. If so
30 // and this receives a |-mouseUp:|, then this will click itself.
31 BOOL tracking_;
33 // In order to get hover effects when the menu is sticky-opened, a tracking
34 // rect needs to be installed on the button.
35 NSTrackingRectTag trackingTag_;
38 @property(nonatomic, readonly, getter=isTracking) BOOL tracking;
40 @end
42 #endif // CHROME_BROWSER_UI_COCOA_WRENCH_MENU_MENU_TRACKED_BUTTON_H_