nsstatusbar

RUMPS Updating Application Title

徘徊边缘 提交于 2021-02-19 07:38:29
问题 So I've been working on a little python application using rumps and I'd like to periodically update the title of the application in the status bar. There appears to be a function in rumps that should do what I'm looking for but I can't seem to get it to work, here's an adaption of some example code that shows the issue I'm running into: import rumps class AwesomeStatusBarApp(rumps.App): def __init__(self): super(AwesomeStatusBarApp, self).__init__("Awesome App") self.menu = ["updating"]

Swift: Right/Left click on NSStatusBar

ぃ、小莉子 提交于 2020-01-03 05:58:08
问题 I'm building a NSStatusBar app and want to call different functions depending on if the user clicked left- or right on the icon. Here is what I have so far: let statusItem = NSStatusBar.systemStatusBar().statusItemWithLength(-1) func applicationDidFinishLaunching(aNotification: NSNotification) { let icon = NSImage(named: "statusIcon") icon?.setTemplate(true) statusItem.image = icon statusItem.menu = statusMenu } With this it shows up the statusMenu by every click. How can I distinguish the

Detect click on OS X menu bar?

一曲冷凌霜 提交于 2019-12-23 00:51:31
问题 I'm curious if there's a trick to detecting a click on the Menu Bar as a whole. I know I can detect a click on an NSStatusItem or NSMenu, but I am looking for events pertaining to the empty space of the Menu Bar. Looking through the documentation, it does not seem possible. However, I wanted to know if anyone had a workaround for this functionality? 回答1: You can install a local event monitor using NSEvent addLocalMonitorForEventsMatchingMask:handler: See the documentation located here. 来源:

NSPopover transiency when popover is in status bar

眉间皱痕 提交于 2019-12-20 08:44:33
问题 I'm making an app which lives in status bar. When status item is clicked, NSPopover pops up. It looks like this: Here's the problem: I want it to be "transient", that is if I click anywhere outside of the popover, it will close. And while NSPopoverBehaviorTransient works fine when popover is in a window, it doesn't work when it's in status bar. How can I implement such behavior myself? 回答1: It turned out to be easy: - (IBAction)openPopover:(id)sender { // (open popover) if

NSTextField isn't active on NSPopover attached to NSStatusItem

倖福魔咒の 提交于 2019-12-14 03:11:47
问题 I have a NSStatusItem created like this: statusItem = [[NSStatusBar systemStatusBar] statusItemWithLength:NSVariableStatusItemLength]; [statusItem setTitle:@"DS"]; [statusItem setHighlightMode:YES]; [statusItem setAction:@selector(StatusClicked:)]; [statusItem setTarget:self]; I also have a popover with customview. On the view I have textfield: http://d.pr/i/CWbr My popover is shown like this: - (void)StatusClicked:(id)sender { [self.popover showRelativeToRect:[sender bounds] ofView:sender

NSStatusBar drag & drop with menu

不想你离开。 提交于 2019-12-11 11:53:43
问题 I'm familiar with the technique described here: Drag and Drop with NSStatusItem to make an NSStatusBar item that can handle file drag & drop. What is the proper method for having a status bar item that supports both drag & drop and regular menu interactions, much like the Cloudapp icon does. I want users to be able to left click the NSStatusItem to see the normal menu listing as well as allow for file drag and drop functionality. It seems to me like I have to write all my own click handler

NSStatusItem appears briefly on launch, but promptly disappears

心不动则不痛 提交于 2019-12-10 12:37:06
问题 I'm starting to get back into Cocoa development after not working on anything for a few months. Originally when I started I was using Snow Leopard and Xcode 3. I'm now running Lion with Xcode 4.2 and I'm running into some issues that I hadn't run into before. I believe it's probably the fact that I've never used ARC before, so I'm sure I'm missing something. I'm trying to create Statusbar application, without a main window, or dock icon. When I run the application the Statusbar icon for my

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(