• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright 2013 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.
4
5#import "ui/base/cocoa/controls/hover_image_menu_button.h"
6
7#include "base/mac/foundation_util.h"
8#import "ui/base/cocoa/controls/hover_image_menu_button_cell.h"
9
10@implementation HoverImageMenuButton
11
12+ (Class)cellClass {
13  return [HoverImageMenuButtonCell class];
14}
15
16- (id)initWithFrame:(NSRect)frameRect
17          pullsDown:(BOOL)flag {
18  if ((self = [super initWithFrame:frameRect
19                         pullsDown:flag])) {
20    trackingArea_.reset(
21        [[CrTrackingArea alloc] initWithRect:NSZeroRect
22                                     options:NSTrackingInVisibleRect |
23                                             NSTrackingMouseEnteredAndExited |
24                                             NSTrackingActiveInKeyWindow
25                                       owner:self
26                                    userInfo:nil]);
27    [self addTrackingArea:trackingArea_.get()];
28  }
29  return self;
30}
31
32- (HoverImageMenuButtonCell*)hoverImageMenuButtonCell {
33  return base::mac::ObjCCastStrict<HoverImageMenuButtonCell>([self cell]);
34}
35
36- (void)mouseEntered:(NSEvent*)theEvent {
37  [[self cell] setHovered:YES];
38}
39
40- (void)mouseExited:(NSEvent*)theEvent {
41  [[self cell] setHovered:NO];
42}
43
44@end
45