cocoa

Cocoa: How to set window title from within view controller in Swift?

点点圈 提交于 2020-05-25 04:03:06
问题 I've tried to build on a Cocoa app which uses storyboard and Swift in Xcode 6. However, when I tried to alter the title of window from within NSViewController , the following code doesn't work. self.title = "changed label" When I wrote the above code in viewDidLoad() function, the resultant app's title still remains window . Also, the following code causes an error, since View Controller doesn't have such property as window . self.window.title = "changed label" So how can I change the title

Cocoa: How to set window title from within view controller in Swift?

寵の児 提交于 2020-05-25 04:02:05
问题 I've tried to build on a Cocoa app which uses storyboard and Swift in Xcode 6. However, when I tried to alter the title of window from within NSViewController , the following code doesn't work. self.title = "changed label" When I wrote the above code in viewDidLoad() function, the resultant app's title still remains window . Also, the following code causes an error, since View Controller doesn't have such property as window . self.window.title = "changed label" So how can I change the title

NSApplication responder chain for arrow keys

℡╲_俬逩灬. 提交于 2020-05-24 05:33:08
问题 I have an NSTextField in my window and 4 menu items with key equivalents ← ↑ → ↓ . When the text field is selected and I press an arrow key, I would expect the cursor to move in the text field but instead the corresponding menu item action is performed. So there has to be an issue in the responder chain. To figure out what's wrong I've watched WWDC 2010 Session 145 – Key Event Handling in Cocoa Applications mentioned in this NSMenuItem KeyEquivalent space " " bug thread. The event flow for

There is no plus button when I click “show tab bar”

生来就可爱ヽ(ⅴ<●) 提交于 2020-05-23 11:42:08
问题 I'm working on a web browser app for mac. I was playing with the test app then I saw this option... When I clicked on that, I saw this... But there was no plus button. Is there any way I can show the plus button in the tab? Please don't send me the link to the Apple documentation because it doesn't give the exact code. BTW, this is not a document based app 回答1: This is an app developed by Apple Inc. You can download it. In this app, you can add tabs. So change the name of this app and you're

Finder Sync/Overlays Extension not launching

孤人 提交于 2020-05-17 07:46:09
问题 I am facing an issue where finder overlays sync icons are not shown. Here is the code that I tried: NSString* bundleID = @"com.my.myapp"; NSString* extBundleID = [NSString stringWithFormat:@"%@.finderoverlays", bundleID]; NSString* runCommand = [NSString stringWithFormat:@"pluginkit -e use -i %@", extBundleID]; NSLog(@"runcommand= %s", runCommand.UTF8String); int result = system(runCommand.UTF8String); NSLog(@"setting up finder overlays, returned = %d", result); The result is always 0, but

Add CATextLayer on Top of NSImageView

蓝咒 提交于 2020-05-15 21:35:40
问题 I'm trying to display text on top of an NSImage.I use the following code let myTextLayer = CATextLayer() myTextLayer.string = "My text" myTextLayer.foregroundColor = NSColor.cyan.cgColor myTextLayer.frame = self.img_view.bounds self.img_view.layer=myTextLayer; This keeps producing empty NSImageView 回答1: You needs explicitly say NSImageView wantsLayer before use layers, like below self.img_view.wantsLayer = true let myTextLayer = CATextLayer() myTextLayer.string = "My text" myTextLayer

Monitoring NSEvents using addGlobalMonitorForEvents missing gesture events

蓝咒 提交于 2020-05-15 07:58:12
问题 I have really strange problem: My background service is trying to detect, if user is idle by monitoring NSEvents using NSEvent.addGlobalMonitorForEvents(matching: mask, handler: handler) . So far so good, I'm able to get mouse and keyboard notifications like mouseMoved, leftMouseDown or keyDown without problems. But I noticed, that I don't receive events for gestures like 3 fingers swipe to show mission control. At the moment I put all NSEventMask values into matching: , because I want to

Monitoring NSEvents using addGlobalMonitorForEvents missing gesture events

戏子无情 提交于 2020-05-15 07:58:04
问题 I have really strange problem: My background service is trying to detect, if user is idle by monitoring NSEvents using NSEvent.addGlobalMonitorForEvents(matching: mask, handler: handler) . So far so good, I'm able to get mouse and keyboard notifications like mouseMoved, leftMouseDown or keyDown without problems. But I noticed, that I don't receive events for gestures like 3 fingers swipe to show mission control. At the moment I put all NSEventMask values into matching: , because I want to

Is it possible to use Cocoa API with Python?

a 夏天 提交于 2020-05-14 08:50:11
问题 I was wondering if it is possible to use Cocoa (Apple's API) with Python, so being able to run any code like in this link, so NSWorkspace functions and so on, this might be a super stupid question, but I was still wondering if it was possible... 回答1: Yes. There are Python packages, kind of wrappers around Objective-C, install them like: $ pip install pyobjc-core $ pip pyobjc-framework-Cocoa $ pip pyobjc-framework-Quartz https://pypi.org/project/pyobjc-framework-Cocoa/ 回答2: MacOS by default

Is it possible to use Cocoa API with Python?

一个人想着一个人 提交于 2020-05-14 08:48:27
问题 I was wondering if it is possible to use Cocoa (Apple's API) with Python, so being able to run any code like in this link, so NSWorkspace functions and so on, this might be a super stupid question, but I was still wondering if it was possible... 回答1: Yes. There are Python packages, kind of wrappers around Objective-C, install them like: $ pip install pyobjc-core $ pip pyobjc-framework-Cocoa $ pip pyobjc-framework-Quartz https://pypi.org/project/pyobjc-framework-Cocoa/ 回答2: MacOS by default