替代NSStatusItem.button(NSStatusBarButton)OSX 10.9

时间:2015-10-15 14:55:48

标签: macos swift cocoa osx-mavericks

我正在使用状态栏按钮构建应用,我使用NSPopover在其上显示视图。执行此操作的代码如下所示:

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

我想在OSX 10.9中执行相同的功能。该按钮不可用< 10.10。我查看了源代码,我发现我需要的大部分属性都在那里,我只需要一种方法来模拟按钮边界,然后查看 - 此时。怎么会这样呢?

完全替换NSStatusItem.button的建议也非常有用。

1 个答案:

答案 0 :(得分:0)

在Mavericks中使用@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 的弃用实现。

这是界面:

    var svgContainer = d3.select("#" + network.container_id)
                         .append("svg")
                         .attr("id", "svg_network")
                         .attr("width", width)
                         .on("load", function (d, i) { console.log('svg');})
                         .attr("height", height);