nsstatusitem

How can I vertically align my status bar item text?

六眼飞鱼酱① 提交于 2019-12-10 02:39:58
问题 Left one on the picture is the date and time from Apple and one is my application one. As you may see the text of my application appears lower than the Apple one. Which doesn't look pretty. How can this be resolved? self.statusBarItem.image = nil self.statusBarItem.button?.imagePosition = .NoImage self.statusBarItem.button?.title = "Sun 5 Jun 13:35" 回答1: You could do it in offset. You cannot do it like this since it needs to be done on the status item button bar. button.frame = CGRectMake(0.0

Custom NSView in NSMenuItem not receiving mouse events

二次信任 提交于 2019-12-09 04:46:40
问题 I have an NSMenu popping out of an NSStatusItem using popUpStatusItemMenu. These NSMenuItems show a bunch of different links, and each one is connected with setAction: to the openLink: method of a target. This arrangement has been working fine for a long time. The user chooses a link from the menu and the openLink: method then deals with it. Unfortunately, I recently decided to experiment with using NSMenuItem's setView: method to provide a nicer/slicker interface. Basically, I just stopped

Detect left and right click events on NSStatusItem (Swift)

回眸只為那壹抹淺笑 提交于 2019-12-08 08:10:45
问题 I’m building a status bar app and want to call different actions depending on if the user clicked left or right. Here’s what I have so far: var statusItem = NSStatusBar.system().statusItem(withLength: -1) statusItem.action = #selector(AppDelegate.doSomeAction(sender:)) let leftClick = NSEventMask.leftMouseDown let rightClick = NSEventMask.rightMouseDown statusItem.button?.sendAction(on: leftClick) statusItem.button?.sendAction(on: rightClick) func doSomeAction(sender: NSStatusItem) { print(

NSView added to NSStatusItem button has an opaque border

こ雲淡風輕ζ 提交于 2019-12-08 06:35:58
问题 I have been working on a NSStatusItem user agent that adds a NSView subclass as a subview of NSStatusItem.button to provide animated icons. When left clicking on the icon, there is a noticeable opaque border around the view. The view subclass's init reads: - (instancetype)initWithFrame:(NSRect )rect { self = [super initWithFrame:rect]; if ( self ) { self.wantsLayer = YES; self.layer.opaque = NO; [self.layer addSublayer:self.background]; [self.layer addSublayer:self.foreground]; [self.layer

Cocoa - Capturing NSStatusItem mouse hover event

血红的双手。 提交于 2019-12-07 18:23:29
问题 How do I execute a function when a user's mouse hovers over my NSStatusItem? 回答1: If you assign a custom NSView to your NSStatusItem 's view property, you can override the NSResponder methods mouseEntered: , mouseMoved: and mouseExited: . 来源: https://stackoverflow.com/questions/5114974/cocoa-capturing-nsstatusitem-mouse-hover-event

NSStatusItem's menu are not shown in Full Screen Model for the Mac os 10.13.1

我与影子孤独终老i 提交于 2019-12-07 12:02:52
问题 all: I have added one NSStatusItem in the status bar for my test app, and it works well in Mac ox 10.12, not only normal model, but also full screen model. When i switch to Mac os 10.13, it is failed to show the menu in the full screen model. self.statusItem = [[NSStatusBar systemStatusBar] statusItemWithLength:NSVariableStatusItemLength]; self.statusItem.highlightMode = YES; self.statusItem.menu = self.dummyMenu; [self.statusItem.menu setDelegate:self]; self.statusItem.image = image; does

How do I use an indeterminate status indicator as the image for an NSStatusItem?

核能气质少年 提交于 2019-12-07 09:21:03
问题 I have an application that is an NSStatusItem . It has a few different modes, each of which require an external process to be launched, during which the icon is simply highlighted, and appears to be frozen. I want to use the -setImage: method (or reasonable facsimile) to display something along the lines of a "spinner" commonly seen in web applications and all over OS X. Is there any native method for accomplishing this (e.g. some instance of NSProgressIndicator ?) or must I manually display

Highlight NSStatusItem when triggered programmatically

风格不统一 提交于 2019-12-07 06:59:05
问题 I have an NSStatusItem with an attached menu that I'm triggering with a global hotkey. If I click the menu item I get the highlight as usual, if I use the hotkey the highlight isn't triggered. Does anyone know a way to trigger the highlight? I've tried overriding the view and drawing it myself in drawRect but if there is a nicer way to do it I'd love to hear. Thanks! The reason I don't want to override the view is then I have to handle icon positioning, clicking to activate the menu, etc. 回答1

NSProgressIndicator in NSStatusItem

孤人 提交于 2019-12-06 15:44:41
问题 I have NSStatusItem with a custom NSView which shows images. Whether the menu is opened or not it show different images just like that: isMenuVisible = NO; - (void)awakeFromNib { statusItem = [[NSStatusBar systemStatusBar] statusItemWithLength:NSVariableStatusItemLength]; [statusItem retain]; dragStatusView = [[DragStatusView alloc] init]; [dragStatusView retain]; dragStatusView.statusItem = statusItem; [dragStatusView setMenu:statusMenu]; [dragStatusView setToolTip:NSLocalizedString(@

Cocoa - How to bring particular window to come in foreground from StatusMenu

让人想犯罪 __ 提交于 2019-12-06 13:55:25
问题 I am working on an Mac Application. I have set Application is agent (UIElement) = YES in plist, and App have a Window (lets say Popup Window) that acts as custom PopOver for StatusMenu. One more window is there (lets say Window B) that should opened on selecting a Link from StatusMenu that i have made, but Problems that I am facing are as follow: On Application launch, When I opens status Menu It also showing Window B , that actually should not be Shown. Window B is allocated and initialised