appkit

Setting Multiline Title To NSButton In Cocoa App

不打扰是莪最后的温柔 提交于 2019-12-13 08:17:42
问题 I understand the NSButton guidelines for setting title to NSButton, No offence but the requirement should be fulfilled in my case. I want to show NSButton title in two lines. NSButton *btn = [[NSButton alloc] init]; [btn setTitle:@"multiple line text if longer title"]; the result I wanted was kind of below -: 回答1: I have fulfilled the requirement by subclassing the NSButton and then checked the title's string length to divide string accordingly to show it in two line. NSArray *arrStr = [str

Embedding NSStackView as NSTableCellView in NSTableView

那年仲夏 提交于 2019-12-13 06:31:42
问题 I'm currently working on a prototype for a todo type app. I have a table which contains the user tasks. What I want to do is only present the user with pertinent task information. But to edit additional information, they would click on a disclosure button to expand the cell. I was thinking of two possible ways to handle this: Expanding NSTableViewCell Using an NSStackView as the contents of each cell If using the NSTableViewCell, I would probably have two NSViews to represent the cell (top

Cut & paste of files with NSPasteboard

心不动则不痛 提交于 2019-12-13 04:16:30
问题 How are we supposed to cut & paste files using NSPasteboard ? Currently I implemented copy and paste by writing and reading file URLs. The problem with cut is, that after I wrote the URL to the pasteboard, I have to remove the file. And when I try to paste the file it doesn't exist anymore and I can't copy it. Should I write something else onto the pasteboard? I also thought about copying the file to a temporary hidden location, but that seems to be a bit inefficient. Is there any other

NSDatePicker misbehaving with arrow keys

霸气de小男生 提交于 2019-12-12 18:27:15
问题 I have used NSDatePicker s (without steppers) in the cells of a column in an NSTableView . The date pickers are used to set a duration of time in hours, minutes and seconds. If I highlight one of the controls and use the arrow keys to set the values, the date picker displays some weird behaviour: Seconds increment by two for every time I press up arrow (whereas it should increment by one for each key press); Seconds do not decrement when I press down arrow; Every time I increment and

Replacements for the deprecated NSNibLoading methods (loadNibFile:, loadNibNamed:, etc.)?

大城市里の小女人 提交于 2019-12-12 07:46:36
问题 I have found that the NSNibLoading methods in NSBundle: +[NSBundle loadNibFile:externalNameTable:withZone:] +[NSBundle loadNibNamed:owner:] -[NSBundle loadNibFile:externalNameTable:withZone:] have all been marked deprecated in 10.8 - what is the proper way to load the nibs in 10.8 and later? I'm trying to create a custom sheet in my app, do I have to create NSWindowController with initWithWindowNibName for the custom sheet? 回答1: The NSBundle class method loadNibNamed:owner: is deprecated in

NSTableView: selecting non-editable CELLS and not ROWS

两盒软妹~` 提交于 2019-12-11 19:43:48
问题 I've tried numerous combinations of suggested options from other posts, but I can't seem to get a cell-bassed NSTableView populated with non-editable NSTextFieldCell to select the CELL and not the row. I've tried: [[col dataCell] setEditable:NO]; [[col dataCell] setSelectable:YES]; [col setEditable:YES]; and tried delegates: - (BOOL)tableView:(NSTableView *)aTableView shouldSelectRow:(NSInteger)rowIndex; and - (BOOL)shouldFocusCell:(NSCell *)cell atColumn:(NSInteger)column row:(NSInteger)row;

Symbol not found _OBJC_IVAR_$_NSView._layer (in AppKit) only on 10.7, works fine on 10.8 and 10.9

倾然丶 夕夏残阳落幕 提交于 2019-12-11 19:13:24
问题 My mac cocoa app works fine on 10.8 and 10.9 except on 10.7 (fresh install) with this error at start : Symbol not found: _OBJC_IVAR_$_NSView._layer Process: xxx [875] Path: /Users/USER/Desktop/xxx.app/Contents/MacOS/xxx Identifier: com.xxx.xxx Version: 1.0 (1) Code Type: X86-64 (Native) Parent Process: launchd [127] Date/Time: 2014-02-13 17:44:24.208 +0100 OS Version: Mac OS X 10.7.5 (11G63) Report Version: 9 Crashed Thread: 0 Exception Type: EXC_BREAKPOINT (SIGTRAP) Exception Codes:

NSTextView textDidChange not called through binding

可紊 提交于 2019-12-11 17:44:13
问题 I have NSTextViews where I need to track the current end point of the text to place interface elements. I bind a model string to NSBindingName.value on the text view. When the text is edited I update the location of my interface elements in func textDidChange(_ notification: Notification) ...as a delegate to the NSTextView. However, if my model is the source of a string update, this delegate method is never called, even though the text is correctly updated in the NSTextView. So, am I doing

Position the search box at the left of the title bar

旧巷老猫 提交于 2019-12-11 11:16:57
问题 I'm using INAppStoreWindow for my application. I put an NSSearchButton in the title bar of the application. INAppStoreWindow *aWindow = (INAppStoreWindow*)self.window; aWindow.titleBarHeight = 60.0; aWindow.showsTitle = YES; NSView *titleBarView = aWindow.titleBarView; NSSize buttonSize = NSMakeSize(200.f, 100.f); NSRect buttonFrame = NSMakeRect(NSMidX(titleBarView.bounds) - (buttonSize.width / 2.f), NSMidY(titleBarView.bounds) - (buttonSize.height / 2.f), buttonSize.width, buttonSize.height)

Storing downloaded files in Cocoa

霸气de小男生 提交于 2019-12-11 11:08:19
问题 I am developing a Cocoa application, and it requires 10.7+. So, I will gladly use the new shiny APIs. What I would like to do is download some MP3s and probably some XML data from our back-end server, and store it on the user's Mac. I would much like to store it within the "application.app" directory, alongside the initial resources that are bundled with the application. Can I do that? Store files within the application.app? If not, where is the preferred directory to store the additional