2015-10-15 39 views
0

我正在構建一個狀態欄按鈕的應用程序,我正在使用NSPopover在其上顯示視圖。做到這一點的代碼如下所示:替代NSStatusItem.button(NSStatusBarButton)OSX 10.9

popover.showRelativeToRect(button.bounds, ofView: button, preferredEdge: NSRectEdge.MinY)

我想在OSX 10.9做到這一點相同的功能。該按鈕不可用< 10.10。我查看了源代碼,發現我需要的大多數屬性都在那裏,我只需要一種方法來模擬按鈕邊界,然後查看 - 在這一點上。怎麼能這樣呢?

完全替代NSStatusItem.button的建議也非常有用。

+0

我能問爲什麼我越來越下降投票? – jQwierdy

回答

0

在小牛隊中,使用了不推薦使用的NSStatusItem實現。

這是接口:

@interface NSStatusItem (NSStatusItemDeprecated) 

/* 
These are softly deprecated methods of NSStatusItem. 
Their past and current behavior is to forward their calls onto the button property. 
They will be formally deprecated in a later release. 
*/ 
@property (nullable) SEL action; 
@property (nullable) SEL doubleAction; 
@property (nullable, weak) id target; 
@property (nullable, copy) NSString *title; 
@property (nullable, copy) NSAttributedString *attributedTitle; 
@property (nullable, strong) NSImage *image; 
@property (nullable, strong) NSImage *alternateImage; 
@property (getter=isEnabled) BOOL enabled; 
@property BOOL highlightMode; 
@property (nullable, copy) NSString *toolTip; 
- (NSInteger)sendActionOn:(NSInteger)mask; 

/* 
Custom views should not be set on a status item. 
The button property with a template image will allow proper styling of the status item in various states and contexts and should be used instead. 
*/ 
@property (nullable, strong) NSView *view; 
- (void)drawStatusBarBackgroundInRect:(NSRect)rect withHighlight:(BOOL)highlight; 
- (void)popUpStatusItemMenu:(NSMenu*)menu; 

@end