appkit

Allow click and dragging a view to drag the window itself?

◇◆丶佛笑我妖孽 提交于 2019-11-30 04:48:46
I'm using a textured window that has a tab bar along the top of it, just below the title bar. I've used -setContentBorderThickness:forEdge: on the window to make the gradient look right, and to make sure sheets slide out from the right position. What's not working however, is dragging the window around. It works if I click and drag the area that's actually the title bar, but since the title bar gradient spills into a (potentially/often empty) tab bar, it's really easy to click too low and it feels really frustrating when you try to drag and realise the window is not moving. I notice NSToolbar

Resizing window to view controller size in storyboard

夙愿已清 提交于 2019-11-30 03:02:18
问题 I am working on Xcode 6.1.1 on OSX 10.10. I am trying out storyboards for Mac apps. I have a NSTabViewController using the new NSTabViewControllerTabStyleToolbar tabStyle and it is set as the default view controller for the window controller. How do I make my window resize according to the current selected view controller? Is it possible to do entirely in Interface Builder? Here is what my storyboard looks like: 回答1: The auto layout answer is half of it. You need to set the

How do you use the dark vibrancy on an NSWindow?

萝らか妹 提交于 2019-11-30 01:57:44
What is the correct way to use the Vibrant Dark ( NSAppearanceNameVibrantDark ) or Vibrant Light ( NSAppearanceNameVibrantLight ) modes with an NSWindow ? I'm building an application and would like to offer the new Vibrant Dark appearance as an option for the main application's NSWindow . The window itself is a pretty straight forward window with an NSToolbar across the top and a scroll view as the main content area. There's plenty of information from Apple on using the new vibrancy appearances in conjunction with an NSVisualEffectsView , but I'm looking for clarification on how to use those

How to get the physical display resolution on MacOS?

谁说胖子不能爱 提交于 2019-11-29 16:32:29
I'm looking to find the value that "About this Mac" shows (2560 x 1600 on my 13" MBP). I have tried CGDisplayBounds and NSScreen.main, both do not return those values but instead return what is used internal for rendering / measuring. as by Kens suggestion: let modes = CGDisplayCopyAllDisplayModes(CGMainDisplayID(), [kCGDisplayShowDuplicateLowResolutionModes: kCFBooleanTrue] as CFDictionary) as! [CGDisplayMode] for mode in modes { let flags = String(format:"%02X", mode.ioFlags) print("\(mode.pixelWidth)x\(mode.pixelHeight) \(mode.width)x\(mode.height) 0x\(flags)") } Output is: 2560x1600

View-based NSOutlineView without NIB?

不想你离开。 提交于 2019-11-29 14:28:59
问题 NSOutlineView is a subclass of NSTableView . And currently, NSTableView supports two implementations. Cell-based. View-based. To make OSX 10.8 Finder style side bar ( with automatic gray Icon styling ), need to use view-based table view with source-list highlight style. With NIBs, this is typical job. Nothing hard. (see SidebarDemo) But I want to avoid any NIBs or Interface Builder. I want make the side bar purely programmatically. In this case, I have big problem. AFAIK, there's no way to

Allow click and dragging a view to drag the window itself?

元气小坏坏 提交于 2019-11-29 02:16:34
问题 I'm using a textured window that has a tab bar along the top of it, just below the title bar. I've used -setContentBorderThickness:forEdge: on the window to make the gradient look right, and to make sure sheets slide out from the right position. What's not working however, is dragging the window around. It works if I click and drag the area that's actually the title bar, but since the title bar gradient spills into a (potentially/often empty) tab bar, it's really easy to click too low and it

Get Certificates in Keychain

拜拜、爱过 提交于 2019-11-28 19:41:45
I've looked over the Security framework documentation but I can't seem to be able to find a way to get all of the certificates on a given keychain. Are there methods to accomplish this? After mining the documentation, header files, and source files, I’ve come up with the following code: #import <Security/Security.h> - (void)logMessageForStatus:(OSStatus)status functionName:(NSString *)functionName { CFStringRef errorMessage; errorMessage = SecCopyErrorMessageString(status, NULL); NSLog(@"error after %@: %@", functionName, (NSString *)errorMessage); CFRelease(errorMessage); } - (void

How do I draw the desktop on Mac OS X?

限于喜欢 提交于 2019-11-28 17:19:56
I want to draw the desktop on Mac OS X (Snow Leopard). Specifically, I want to achieve the same effect as running: /System/Library/Frameworks/ScreenSaver.framework/Resources/ ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine -background (If you’re not near your computer, this displays the screensaver where you would normally see your desktop background.) I know how to make a window without a border (by subclassing NSWindow and overriding initWithContentRect:styleMask:backing:defer: to set the window style to NSBorderlessWindowMask) and without a shadow (setHasShadow:NO.) I know that I can

UITextView – can't set underline or strikethrough attributes on text?

隐身守侯 提交于 2019-11-28 13:21:08
I'm getting runtime failures whenever I try to set underline or strikethrough attributes on the attributedText of a UITextView. Other properties, like font and background color have no problems. Here's a code snippet. All I have is a test project with a single UITextView. I'm on iOS 11. class ViewController: UIViewController { @IBOutlet weak var myTextView: UITextView! var myMutableString = NSMutableAttributedString(string: "") override func viewDidLoad() { super.viewDidLoad() let string = "The cow jumped over the moon" as NSString myMutableString = NSMutableAttributedString(string: string as

Prevent selecting all tokens in NSTokenField

一曲冷凌霜 提交于 2019-11-28 08:50:29
Is there any way to prevent the NSTokenField to select everything when pressing the ENTER key or when making to the first responder maybe using the TAB key? An NSTokenField is a subclass of NSTextField. There's no easy, direct way to directly manipulate the selection of these classes (aside from -selectText:, which selects all). To do this when it becomes the first responder, you'll need to subclass NSTokenField (remember to set the class of the field in your XIB to that of your custom subclass) and override -becomeFirstResponder like so: - (BOOL)becomeFirstResponder { if ([super