nstableview

NSTextView or NSTextField automatically resize bounds / frame?

江枫思渺然 提交于 2019-12-11 18:18:04
问题 I'm trying to use either an NSTextView or NSTextField which displays text that I am adding via textField.stringValue = [dictionary objectForKey:@"info"]; The problem is I need the bounds / frame of the text area to vertically re-size to show all of the text. The text varies from a couple of words (1 line) to a paragraph or two. When I try [textField sizeToFit]; It re-sizes the whole thing down to a single line which is absurdly too long (and goes off view). I need it to auto re-size its width

Implementing NSTableViewRowAction using Swift

风格不统一 提交于 2019-12-11 17:58:58
问题 This should be simple but I cannot understand how to implement this action. I found this reference using objective-c but I want to do this using swift: - (NSArray<NSTableViewRowAction *> *)tableView:(NSTableView *)tableView rowActionsForRow:(NSInteger)row edge:(NSTableRowActionEdge)edge { NSTableViewRowAction *action = [NSTableViewRowAction rowActionWithStyle:NSTableViewRowActionStyleDestructive title:@"Delete" handler:^(NSTableViewRowAction * _Nonnull action, NSInteger row) { // TODO: You

Prevent NSTableView from saving new row until user fills values

倾然丶 夕夏残阳落幕 提交于 2019-12-11 17:23:29
问题 I'm working on a preferences window for my app, where the user can add and remove presets using NSTableView . A preset is defined as: struct Preset: Codable { var name: String var value: Int } These presets should be persisted to UserDefaults . My goal is to write as little code as possible, and what little is written should be generic code, so my project makes use of NSUserDefaultsController , NSArrayController and Cocoa Bindings. Seeing as array, string and integer types are available in

How to insert a row in tableView without using reloadData function in Cocoa

℡╲_俬逩灬. 提交于 2019-12-11 16:25:02
问题 I been working on a self taught project in Cocoa . Trying to replicate how the media player playlist works(Play,Add and Delete and etc...). So far, I have managed to populate a tableview from the directory using NSOpenPanel . I can able to insert a new files to the tableview and play selected sound files using AVAudioPlayer . Everything works as expected. But When, I try to insert a new row to the tableView while the audioPlayer is playing . It updates the entire tableView and i am getting

Sorting a viewbased tableview with multiple sort descriptors doesn't work

耗尽温柔 提交于 2019-12-11 15:19:51
问题 I cannot get sorting working on a view based tableview for a CoreData App using multiple sort descriptors. I have 2 columns, my first column has "bank" and "accountNickName" as values , my second column has "bankAccount". I want to sort by "bank" then "accountNickName" and then by "bankAccount". If I click on the 1st column. I want to sort by "bankAccount", then "bank", then "accountNickName". If I click on the second column. Creating an array of sortDescriptors and bind this to my

macOS 10.13 EXEC_BAD_ACCESS caused by subclassing NSTableView or NSScrollView

核能气质少年 提交于 2019-12-11 14:13:24
问题 I'm facing a rather odd problem. With subclassing some NSViews, NSTableView and NSScrollView to be specific. Situation : I'm working on a quite old (ca. 7 year) project for macOS. The codebase is about 50% objc and 50% swift 3.2 and uses XIB files for the individual views. The application runs smoothly on 10.10 - 10.12 but it crashes on 10.13 pretty much instantly. The backtrace shows the following: * thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address

When NSTableview Load second time its customcell Subview's change it's position how to solve

廉价感情. 提交于 2019-12-11 11:42:11
问题 I am new for cocoa OSX application might be this question is simple but i try my best to find out this issue and at the end i asking question here. I am creating NSWindowViewController and in side it i Used NSTableview with Customcell. In customeCell i used NSView (customView) and all Cell IBOutlet put in side NSView. When First time that NSWindowViewController load that show fine but after close the window and again i open it. its NSTextField IBOutlet change its position top to bottom of the

How to sort NSTableView in Swift using sortDescriptors?

Deadly 提交于 2019-12-11 09:41:49
问题 I use view-based NSTableView in my Cocoa app which is written in Swift, and want to implement a sort functionality on two table columns. However, in Objective-C, you can implement it by first setting the "Sort Key" in Attribute Inspector, and then implement the data source delegate method named tableView: sortDescriptorsDidChange: . However, this method takes sortDescriptor as a parameter and lets developers use it within the method, like so: - (void) tableView:( NSTableView *) tableView

How to make NSArrayController preservesSelection work for custom object?

无人久伴 提交于 2019-12-11 09:05:59
问题 I have a Cocoa app with a view-based table view bound to an NSArrayController with a list of custom Employee objects. The table view shows the list of employees. In a subview, the employee's details can be changed. Everything is set up, so that when an employee's details are changed, the table view contents are reloaded, showing the changes. So far, so good. Now NSArrayController has the ability to preserve the selected object across reloads via preservesSelection . For my custom Employee

Cocoa QuickLook initiated by NSTableView Cell

徘徊边缘 提交于 2019-12-11 07:30:11
问题 I have an NSTableView that contains 2 different Columns - one is an NSImageCell that shows a file icon, and the second is a custom subclass of NSTextFieldCell that contains a quick look button on the right of the text. When I click the Quick Look button, the following code is invoked: [[QLPreviewPanel sharedPreviewPanel] makeKeyAndOrderFront:nil]; This does it's job and shows the blank Quick Look panel saying "No Items Selected." After I did a bit of research on the internet, I implemented a