cocoa

Customise NSPathControl

雨燕双飞 提交于 2020-04-11 12:01:08
问题 I would like to make a custom NSPathControl . NSPathCell has the method + pathComponentCellClass , where you can return the custom class of the component cells. I have a NSPathComponentCell subclass, which I return right there, but it doesn't work. The method does not get called. Why? In the documentation is says: Subclasses can override this method to return a custom cell class that is automatically used. By default, the method returns [NSPathComponentCell class], or a specialized subclass

Prevent NSCollectionView 'lifting' an item during drag

十年热恋 提交于 2020-04-11 08:32:07
问题 I understand how to get drag and drop working for NSCollectionView but I can't seem to stop it 'lifting' the items off the view. My current solution is to not implement func collectionView(_ collectionView: NSCollectionView, pasteboardWriterForItemAt indexPath: IndexPath) -> NSPasteboardWriting? from NSCollectionViewDelegate to ensure that func collectionView(_ collectionView: NSCollectionView, draggingImageForItemsAt indexPaths: Set<IndexPath>, with event: NSEvent, offset dragImageOffset:

NSView loses mouseMoved/mouseDragged if dragged in from subview

拜拜、爱过 提交于 2020-04-11 04:23:07
问题 A = the parent NSView; B = the child NSView; B has a small NSTrackingArea; B is a small subview of A; A correctly receives mouseMoved and mouseDragged events if moved,clicked, dragged in a empty area. If i click in B and drag the mouse outside of its bounds into A, A does not receive any mouseMoved or mouseDragged events. Can someone point me to what i could do to get the superview A to react to this drag? 回答1: I've observed this and I was able to solve it by doing as follows: Create a

menu item is enabled, but still grayed out

青春壹個敷衍的年華 提交于 2020-04-08 02:51:37
问题 I have a menu with several items created in interface builder. It looks fine there and 'enabled' is checked. But when I run application, all menu items are grayed out. I've checked isEnabled , it returns true. Also, menu items created programmatically (with initWithTitle and without interface builder) work just fine. Am I missing something here? I'm really quite new to OSX development (in fact, this is my first day). Thank you 回答1: Remember to set your menu item's target and ensure that said

menu item is enabled, but still grayed out

北城余情 提交于 2020-04-08 02:50:27
问题 I have a menu with several items created in interface builder. It looks fine there and 'enabled' is checked. But when I run application, all menu items are grayed out. I've checked isEnabled , it returns true. Also, menu items created programmatically (with initWithTitle and without interface builder) work just fine. Am I missing something here? I'm really quite new to OSX development (in fact, this is my first day). Thank you 回答1: Remember to set your menu item's target and ensure that said

menu item is enabled, but still grayed out

断了今生、忘了曾经 提交于 2020-04-08 02:49:00
问题 I have a menu with several items created in interface builder. It looks fine there and 'enabled' is checked. But when I run application, all menu items are grayed out. I've checked isEnabled , it returns true. Also, menu items created programmatically (with initWithTitle and without interface builder) work just fine. Am I missing something here? I'm really quite new to OSX development (in fact, this is my first day). Thank you 回答1: Remember to set your menu item's target and ensure that said

How to use hardcoded file path names with sandbox

瘦欲@ 提交于 2020-04-05 06:26:35
问题 Ok, yes I know now that you can not use hardcoded paths with sandbox. Up to this point I have not delt with sandbox, so I never encountered it. I have a Coredata App (Mac OSx) and I used the default save code and the default path location (user/...../applicationsupport/... This, of coarse, is not acceptable in the sandbox. Without requiring the user to manually open the data file each time the program is launched, is there another way to deal with this? I would appreciate any input

How to apply structs to modeling the data a view controller operates on

落花浮王杯 提交于 2020-03-25 19:20:24
问题 I'm trying to embrace Swift's value types more in my application design, but I'm having some beginner difficulties. I know those generally don't go over well in the StackOverflow format for being opinion-based, but I think there are best-practices here that are probably not particularly subjective. I understand all the theoretical benefits of structs, about avoiding shared mutable state, the copying behaviour that makes it easy to implement "undo", etc., but I have a hard time using it in

How to install custom font in mac programmatically in macOS

风流意气都作罢 提交于 2020-03-24 21:26:56
问题 I am having a mac app in which I have custom font which is not there in my custom font book of application folder in my mac. So, when an app launches, I checked it that if a font is installed in mac or not with the below code. NSArray *fonts = [[NSFontManager sharedFontManager] availableFontFamilies]; if ([fonts containsObject:@"Square721 BT"]) { NSLog(@"Fonts Available"); } else { NSLog(@"No fonts"); } Now, if the font is not already installed, how can I install it programmatically? 回答1: Add

How to install custom font in mac programmatically in macOS

你离开我真会死。 提交于 2020-03-24 21:24:11
问题 I am having a mac app in which I have custom font which is not there in my custom font book of application folder in my mac. So, when an app launches, I checked it that if a font is installed in mac or not with the below code. NSArray *fonts = [[NSFontManager sharedFontManager] availableFontFamilies]; if ([fonts containsObject:@"Square721 BT"]) { NSLog(@"Fonts Available"); } else { NSLog(@"No fonts"); } Now, if the font is not already installed, how can I install it programmatically? 回答1: Add