cocoa

how to bind keyboard shortcut to nsbutton in cocoa

非 Y 不嫁゛ 提交于 2020-05-13 06:21:11
问题 I want to know how to add keyboard shortcuts to buttons for example to press key "R" for pressing button "Reading" and key "M" for pressing button "meaning" where "Reading" and "meaning" are buttons in window.nib file 回答1: Select the button in the NIB. Select the Attributes inspector. Put focus on the "Key equivalent" field. Type the desired keystroke. 来源: https://stackoverflow.com/questions/27428850/how-to-bind-keyboard-shortcut-to-nsbutton-in-cocoa

How to put SwiftUI button into NSToolbar?

为君一笑 提交于 2020-05-13 03:46:41
问题 This is how SwiftUI can be inserted into NSToolbar using an accessory view controller: import SwiftUI import PlaygroundSupport var hostingView = NSHostingView(rootView: ZStack { Color.clear HStack { Text("Hey") Text("SwiftUI") } } .padding() .edgesIgnoringSafeArea(.all) ) hostingView.frame.size = hostingView.fittingSize let titlebarAccessory = NSTitlebarAccessoryViewController() titlebarAccessory.view = hostingView titlebarAccessory.layoutAttribute = .trailing let mask: NSWindow.StyleMask = [

Making Cocoa Application Scriptable Swift

梦想与她 提交于 2020-05-10 18:52:22
问题 Goal I am trying to make my Cocoa Application that has been written in Swift scriptable from Applescript. What I've Done I have created a SDEF file, configured my info.plist and created a class which I think is appropriate. definition.sdef <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE dictionary SYSTEM "file://localhost/System/Library/DTDs/sdef.dtd"> <dictionary title="SamX"> <!-- specific suite(s) for the application follow... --> <suite name="SamX Scripting Suite" code="Samx" description

Making Cocoa Application Scriptable Swift

▼魔方 西西 提交于 2020-05-10 18:46:15
问题 Goal I am trying to make my Cocoa Application that has been written in Swift scriptable from Applescript. What I've Done I have created a SDEF file, configured my info.plist and created a class which I think is appropriate. definition.sdef <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE dictionary SYSTEM "file://localhost/System/Library/DTDs/sdef.dtd"> <dictionary title="SamX"> <!-- specific suite(s) for the application follow... --> <suite name="SamX Scripting Suite" code="Samx" description

Show NSPopover from NSToolbarItem Button

余生颓废 提交于 2020-05-10 09:46:04
问题 I want to show an NSPopover from an NSToolbarItem button in my toolbar. (i.e. positioned below the button). Ideally, I want to pass the NSView of the button to the popover to position it. My question is, how do I get the NSView of the NSToolbarItem ? [toolbarbutton view] always returns nil. 回答1: The answer appears to be in the video for the 2011 WWDC Session 113, "Full Screen and Aqua Changes." Basically, put an NSButton inside the NSToolbaritem and use the view of that. A blog post is here:

Show NSPopover from NSToolbarItem Button

与世无争的帅哥 提交于 2020-05-10 09:45:12
问题 I want to show an NSPopover from an NSToolbarItem button in my toolbar. (i.e. positioned below the button). Ideally, I want to pass the NSView of the button to the popover to position it. My question is, how do I get the NSView of the NSToolbarItem ? [toolbarbutton view] always returns nil. 回答1: The answer appears to be in the video for the 2011 WWDC Session 113, "Full Screen and Aqua Changes." Basically, put an NSButton inside the NSToolbaritem and use the view of that. A blog post is here:

NSArrayController initialization

你。 提交于 2020-05-09 19:52:26
问题 I am having trouble getting an core-data backed NSArrayController to work properly in my code. Below is my code: pageArrayController = [[NSArrayController alloc] initWithContent:nil]; [pageArrayController setManagedObjectContext:[self managedObjectContext]]; [pageArrayController setEntityName:@"Page"]; [pageArrayController setAvoidsEmptySelection:YES]; [pageArrayController setPreservesSelection:YES]; [pageArrayController setSelectsInsertedObjects:YES]; [pageArrayController

Mac OS Cocoa: Draw a simple pixel on a canvas

こ雲淡風輕ζ 提交于 2020-05-09 19:11:31
问题 I wish I would find an answer for this. I have searched and searched and couldn't the right answer. Here is my situation: In a Mac OS Cocoa Application, I want to draw a pixel (actually a few pixels) onto a dedicated area on my application window. I figured, it would be nicer to have a NSImageView placed there (I did so with IB and connected the outlet to my app delegate) and draw on that instead of my NSWindow . How in the world can I do that? Mac OS seems to offer NSBezierPath as the most

React Native Create Custom Component/Library

余生颓废 提交于 2020-05-09 18:11:08
问题 In React Native, there are certain third-party components which compile their own libraries that can be included in your main React project. Examples of such third-party libraries are these: https://github.com/naoufal/react-native-touch-id https://github.com/lazaronixon/react-native-qrcode-reader https://github.com/brentvatne/react-native-modal Now, I would very much like to create my own React Native component with a linked library (iOS only, so I only need the Cocoa library that I would

Opening a gap in NSTableView during drag and drop

牧云@^-^@ 提交于 2020-05-09 17:57:57
问题 I've got a simple, single-column, view-based NSTableView with items in it that can be dragged to reorder them. During drag and drop, I'd like to make it so that a gap for the item-to-be-dropped opens up at the location under the mouse. GarageBand does something like this when you drag to reorder tracks (video here: http://www.screencast.com/t/OmUVHcCNSl). As far as I can tell, there's no built in support for this in NSTableView. Has anyone else tried to add this behavior to NSTableView and