summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cocoa/menu_tracked_button.mm
blob: 654e850243b4d0ac0e91cde08518e6eb66a84fa8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import "chrome/browser/cocoa/menu_tracked_button.h"

@implementation MenuTrackedButton

- (void)mouseEntered:(NSEvent*)theEvent {
  didEnter_ = YES;
  [super mouseEntered:theEvent];
}

- (void)mouseExited:(NSEvent*)theEvent {
  didEnter_ = NO;
  tracking_ = NO;
  [super mouseExited:theEvent];
}

- (void)mouseDragged:(NSEvent*)theEvent {
  tracking_ = !didEnter_;
  [super mouseDragged:theEvent];
}

- (void)mouseUp:(NSEvent*)theEvent {
  if (!tracking_) {
    return [super mouseUp:theEvent];
  }
  [self performClick:self];
}

@end