OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #import "chrome/browser/ui/cocoa/menu_button.h" | 5 #import "chrome/browser/ui/cocoa/menu_button.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/scoped_nsobject.h" | 8 #include "base/memory/scoped_nsobject.h" |
9 #import "chrome/browser/ui/cocoa/clickhold_button_cell.h" | 9 #import "chrome/browser/ui/cocoa/clickhold_button_cell.h" |
10 #import "chrome/browser/ui/cocoa/nsview_additions.h" | |
10 | 11 |
11 @interface MenuButton (Private) | 12 @interface MenuButton (Private) |
12 - (void)showMenu:(BOOL)isDragging; | 13 - (void)showMenu:(BOOL)isDragging; |
13 - (void)clickShowMenu:(id)sender; | 14 - (void)clickShowMenu:(id)sender; |
14 - (void)dragShowMenu:(id)sender; | 15 - (void)dragShowMenu:(id)sender; |
15 @end // @interface MenuButton (Private) | 16 @end // @interface MenuButton (Private) |
16 | 17 |
17 @implementation MenuButton | 18 @implementation MenuButton |
18 | 19 |
19 @synthesize openMenuOnClick = openMenuOnClick_; | 20 @synthesize openMenuOnClick = openMenuOnClick_; |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
130 popUpCell_.reset([[NSPopUpButtonCell alloc] initTextCell:@"" | 131 popUpCell_.reset([[NSPopUpButtonCell alloc] initTextCell:@"" |
131 pullsDown:YES]); | 132 pullsDown:YES]); |
132 } | 133 } |
133 DCHECK(popUpCell_.get()); | 134 DCHECK(popUpCell_.get()); |
134 [popUpCell_ setMenu:[self attachedMenu]]; | 135 [popUpCell_ setMenu:[self attachedMenu]]; |
135 [popUpCell_ selectItem:nil]; | 136 [popUpCell_ selectItem:nil]; |
136 [popUpCell_ attachPopUpWithFrame:frame | 137 [popUpCell_ attachPopUpWithFrame:frame |
137 inView:self]; | 138 inView:self]; |
138 [popUpCell_ performClickWithFrame:frame | 139 [popUpCell_ performClickWithFrame:frame |
139 inView:self]; | 140 inView:self]; |
141 | |
142 if (![self cr_isMouseInView]) { | |
Nico
2011/05/14 21:49:08
Add a comment that says why this is necessary (wha
sail
2011/05/15 20:19:57
Done.
| |
143 if ([[self cell] respondsToSelector:@selector(mouseExited:)]) | |
144 [[self cell] mouseExited:nil]; | |
145 } | |
140 } | 146 } |
141 | 147 |
142 // Called when the button is clicked and released. (Shouldn't happen with | 148 // Called when the button is clicked and released. (Shouldn't happen with |
143 // timeout of 0, though there may be some strange pointing devices out there.) | 149 // timeout of 0, though there may be some strange pointing devices out there.) |
144 - (void)clickShowMenu:(id)sender { | 150 - (void)clickShowMenu:(id)sender { |
145 // This should only be called if openMenuOnClick has been set (which hooks | 151 // This should only be called if openMenuOnClick has been set (which hooks |
146 // up this target-action). | 152 // up this target-action). |
147 DCHECK(openMenuOnClick_); | 153 DCHECK(openMenuOnClick_); |
148 [self showMenu:NO]; | 154 [self showMenu:NO]; |
149 } | 155 } |
150 | 156 |
151 // Called when the button is clicked and dragged/held. | 157 // Called when the button is clicked and dragged/held. |
152 - (void)dragShowMenu:(id)sender { | 158 - (void)dragShowMenu:(id)sender { |
153 // We shouldn't get here unless the menu is enabled. | 159 // We shouldn't get here unless the menu is enabled. |
154 DCHECK([self attachedMenu]); | 160 DCHECK([self attachedMenu]); |
155 [self showMenu:YES]; | 161 [self showMenu:YES]; |
156 } | 162 } |
157 | 163 |
158 @end // @implementation MenuButton (Private) | 164 @end // @implementation MenuButton (Private) |
OLD | NEW |