cocoa

mouseover detection in NSTableView's NSCell?

对着背影说爱祢 提交于 2021-02-18 06:20:24
问题 I am wanting to change the text background color on a tableview's cell when it is hovered upon, similar to how AddressBook "highlights" the label of a contact's element when you mouseover the label names. However I cannot figure out how to accomplish... detecting a mouseover on a particular NSCell and... After detecting the cell his hovered upon, highlighting the text in that cell (not highlighting the entire row as if the user selected that row) As NSCell is not a subclass of NSView this

center programmatically created window

廉价感情. 提交于 2021-02-18 05:32:29
问题 I've been using the example from here to create a custom titlebar-less window: Drawing a custom window on Mac OS X I've found this is the only way i can create a titlebar-less window in Leopard, Snow Leopard and Lion, other methods don't work right either on Leopard or Lion. (If i try to invoke a titlebar-less window via normal NSWindow and IB, it won't start up in Leopard anymore) So far this custom titlebar-less window works great everywhere, but i can't center it, only a hard fixed

NSColor | Creating Color from RGB Values

ⅰ亾dé卋堺 提交于 2021-02-17 20:30:35
问题 In my application, i will get RGB Values as a unsigned character so it will not be more then 255, I am using NSColor API to create the color and will make use of it to draw the font and background color, this is the function that i have written +(NSColor *)getColorFromRGB:(unsigned char)r blue:(unsigned char)b green:(unsigned char)g { CGFloat rFloat = r/255.0; CGFloat gFloat = g/255.0; CGFloat bFloat = b/255.0; // return [NSColor colorWithCalibratedRed:((float)r/255.0) green:((float)g/255.0)

NSColor | Creating Color from RGB Values

纵然是瞬间 提交于 2021-02-17 20:28:20
问题 In my application, i will get RGB Values as a unsigned character so it will not be more then 255, I am using NSColor API to create the color and will make use of it to draw the font and background color, this is the function that i have written +(NSColor *)getColorFromRGB:(unsigned char)r blue:(unsigned char)b green:(unsigned char)g { CGFloat rFloat = r/255.0; CGFloat gFloat = g/255.0; CGFloat bFloat = b/255.0; // return [NSColor colorWithCalibratedRed:((float)r/255.0) green:((float)g/255.0)

How to print an NSOutlineView with NSVIew.printView

烂漫一生 提交于 2021-02-17 06:46:06
问题 I want to print an NSOutlineView. The view is a subview of a window on screen. I noticed the NSView api call printView. So I tried it in a simple minded fashion. In my AppDelegate I have a call: @IBAction func doPrint(_ sender: Any?) { globalOutlineCntrl?.outlineView.printView(self) } So with the window containing the outline on-screen, I issued the doPrint call. The outline on screen looks like this: The doPrint call seems to work, but prints this: Is there anyway to make this work? If not

Why is the local notification I created with UNUserNotificationCenter not shown in the upper-right corner of my screen?

谁说胖子不能爱 提交于 2021-02-17 02:47:26
问题 Running the code below doesn't show the notification in the upper-right corner of my screen (as a banner or alert). The notification is shown in the notification center. I made sure "Do not disturb" is disabled on my system. I also tried both the "Banner" and "Alert" setting in System Preferences -> Notifications -> Name of my app. Source: import Cocoa import UserNotifications @NSApplicationMain class AppDelegate: NSObject, NSApplicationDelegate { func applicationDidFinishLaunching(_

Printing in Cocoa

佐手、 提交于 2021-02-16 15:41:07
问题 I have made a view that pretty much fits A4 page. Now I want to print it. Note that I am not using drawRect or anything like that, just a normal view with subviews and text labels. My problem is that I have a few views on that view which I use layers to put background colors and rounded rects around the items. The subviews don't print, but all text labels print. The _printReport is just a plain window with a view and bunch of text labels. What am I doing wrong and how could I do this better ?

How to correctly display a “progress” sheet modally while using Grand Central Dispatch to process something?

不羁岁月 提交于 2021-02-15 11:45:44
问题 I'm trying to display a sheet on a window containing a single progress bar, to show the progress of some long function running asynchronously using Grand Central Dispatch. I've almost got it, but can't get the sheet to appear to be in focus, probably because I haven't used runModalForWindow: or similar. This is approximately what I'm doing at the moment, it happens as a result of a button press on the main window: // Prepare sheet and show it... [NSApp beginSheet:progressSheet modalForWindow

How to correctly display a “progress” sheet modally while using Grand Central Dispatch to process something?

我的梦境 提交于 2021-02-15 11:45:32
问题 I'm trying to display a sheet on a window containing a single progress bar, to show the progress of some long function running asynchronously using Grand Central Dispatch. I've almost got it, but can't get the sheet to appear to be in focus, probably because I haven't used runModalForWindow: or similar. This is approximately what I'm doing at the moment, it happens as a result of a button press on the main window: // Prepare sheet and show it... [NSApp beginSheet:progressSheet modalForWindow

How to correctly display a “progress” sheet modally while using Grand Central Dispatch to process something?

牧云@^-^@ 提交于 2021-02-15 11:41:12
问题 I'm trying to display a sheet on a window containing a single progress bar, to show the progress of some long function running asynchronously using Grand Central Dispatch. I've almost got it, but can't get the sheet to appear to be in focus, probably because I haven't used runModalForWindow: or similar. This is approximately what I'm doing at the moment, it happens as a result of a button press on the main window: // Prepare sheet and show it... [NSApp beginSheet:progressSheet modalForWindow