Search results for

column

2,046 results found

Post

Replies

Boosts

Views

Activity

Reply to Disabling edit on single-click in view-based NSTableView?
Thanks for the reply. Making the columns uneditable makes no difference, I'm afraid. Are you using cell-based tables by any chance? I used to take that approach with cell-based tables, but with view-based tables you disable editing at the text field level. But if the text fields aren't set to editable, then click-after-delay doesn't work (for when you want to click and then click again instead of triggering the double-click action).
Topic: UI Frameworks SubTopic: AppKit Tags:
Jun ’15
NSTableView setObjectValue not called
My application presents a list of words to the user, who will then select a number of them. They may also edit the words in the table. The table is a single column, cell-based table.The application is very small, so the app delegate is being used as the NSTableViewDataSource and NSTableViewDelegate. The data source is working correctly, as the right words are appearing in the table. I am able to get a list of selected words from the table after the user presses the Done button.The part that is missing is getting edits of words in the table. I have added the - (void)tableView:setObjectValue:forTableColumn:row: method, right next to the methods for populating the table. I put a call to NSLog in the method, but the method is not being called- nothing appears in the console.What might prevent the method from being called? Exactly what user actions will trigger the sending of the message to the table data source?ThanksAndrew
Topic: UI Frameworks SubTopic: AppKit Tags:
4
0
2k
Jun ’15
Reply to How to create collection view that scrolls both ways?
Hi,If there isn't a class somewhere at the web, which does exactly what you need, you have to implement it on your own. I've created a collectionViewLayout with a fixed column with and a variable item height. And yes, you have to do all the calculations yourself. But for a grid-style layout this should by quite easy to implement. I suggest reading some docs but the most important part of a UICollectionViewLayoutAttributes object is the frame, which tells the collection view where to put the collection view items at.Dirk
Topic: UI Frameworks SubTopic: UIKit Tags:
Jun ’15
UICollectionView as Multicolumn Grid
Hi,Is the UICollectionView the best/only way to get a multicolumn grid in Swift? Making an invoice app for the iPad and using the single column tableview with subtext just doesn't seem like a good fit. I've googled some examples but have yet to find a good one. Any guidance would be much appreciated.Thanks,Brandon
1
0
405
Jun ’15
From NSMutableArray to NSMutabledictionnary
Hello Everybody,I have written a script in swift using a NSMutableArray (containing strings).I want to put the result inside a NSMutableDictonnary so I could edit it in NSTableView (containing two columns, one with strings, the other one with checkboxes) and collect information about the checkboxes status. Everything goes fine except when I try to convert the NSMutableArray to NSMutableDictonnary.I don't find the API and the syntax to do that.Could anyone help me?var array : NSMutableArray! = NSMutableArray()var dataArray:[NSMutableDictionary] = [[firstName: , fullTimeEmp: 0]];...contenu = ctlelems[elem] as! Stringarray.addObject((contenu))func numberOfRowsInTableView(aTableView: NSTableView) -> Int { let numberOfRows:Int = array.count println(numberOfRows) return numberOfRows } func tableView(tableView: NSTableView, objectValueForTableColumn tableColumn: NSTableColumn?, row: Int) -> AnyObject? { let object = array[row] as! NSMutableDictionary if ((tableColumn!.identifier) == fullTimeEmp) { ret
0
0
198
Jun ’15
NSTableView row heights with auto layout and bindings
HiIm trying to fix a problem with dynamic row heights with auto layout and bindings which was working fine in an older build of Xcode but which now no longer works. So my new attempt for the most part works but about 30% of my row heights are not correctly calculated. Basically I create a reference NSTableCellView, set my model object as the objectValue which then updates the bindings, set the frame width of the reference cell to the column width then work out the height from there by setting preferredMaxLayoutWidth on the wrapping text field. Here's the code to do the calculation- (CGFloat)tableView:(NSTableView *)tableView heightOfRow:(NSInteger)row { static NSTableCellView *cellView = nil; if (cellView == nil) { NSDictionary *nibs = [tableView registeredNibsByIdentifier]; NSNib *nib = nibs[@MainCellView]; NSArray *topLevelObjects = nil; [nib instantiateWithOwner:nil topLevelObjects:&topLevelObjects]; for (id object in topLevelObjects) { if ([object isKindOfClass:[NSTableCellView class]]) { cel
Topic: UI Frameworks SubTopic: AppKit Tags:
0
0
1.6k
Jun ’15
Reply to NSTableView setObjectValue not called
Ok I threw together a quick and dirty app to test the normal mechanism and it works fineThe app delegate, which again is also the table delegate and data source, looks like this@interface AppDelegate () <NSTableViewDataSource, NSTableViewDelegate> @property (weak) IBOutlet NSWindow *window; @property (nonatomic, strong) NSArray *data; @end @implementation AppDelegate - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { self.data = @[[@{@name:@Jonathan} mutableCopy], [@{@name:@Richard} mutableCopy]]; [self.window makeKeyAndOrderFront:nil]; } - (void)applicationWillTerminate:(NSNotification *)notification { NSLog(@%@, self.data.description); } - (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView { return 2; } - (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row { return [[self.data objectAtIndex:row] valueForKey:tableColumn.identifier]; } - (void)tableView:(NSTableView *)tableView setObjectValue:(id)object forTableCo
Topic: UI Frameworks SubTopic: AppKit Tags:
Jul ’15
Reply to Different Behavior When AppDelegate is Instantiated Programmatically?
Here is the code for my main.swift file - as the code shows, I still use a MainMenu nib that loads the standard menu items in Interface Builder:import Cocoa private func setDelegate( application: NSApplication , delegate: NSApplicationDelegate? ) -> NSApplication { application.delegate = delegate return application } private func runApplication( application: NSApplication = NSApplication.sharedApplication() , delegate: NSApplicationDelegate? = nil , bundle: NSBundle = NSBundle.mainBundle() , nibName: String = MainMenu , var topLevelObjects: NSArray? = nil ) { if bundle.loadNibNamed( nibName , owner: setDelegate(application, delegate: delegate) , topLevelObjects: &topLevelObjects ) { application.run() } else { print(An error was encountered while starting the application.) } } runApplication(delegate: AppDelegate())And here is my AppDelegate file:import Cocoa @NSApplicationMain // This is commented out when I am using main.swift; // That is the only difference in my AppDelegate file between the two scen
Topic: UI Frameworks SubTopic: AppKit Tags:
Jul ’15
NSBrowser....conditionally suppress right-click menu
How can I conditionally suppress NSBrowser's contextual menu? I only want to show a menu, if the right click is on selected row... but when you set the menu property on NSBrowser, it shows it when you right click anywhere on NSBrowser.I tried to use the menuNeedsUpdate: delegate method and check the selected rows in a column...if there's none... set the browser's menu to nil, but it's too late at that point. Would be cool if there were delegate methods for this.Is there any other way besides hiding all the menu items?
Topic: UI Frameworks SubTopic: AppKit Tags:
5
0
509
Jul ’15
Reply to NSTableView setObjectValue not called
Thanks. It looks like the column not having an identifier set was where I went wrong.However, I also found another way to get the edited values from the table. // this bit goes in applicationDidFinishLaunching [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(editingDidEnd:) name:NSControlTextDidEndEditingNotification object:nil]; // this notification is sent by the table cell field editor - (void)editingDidEnd:(NSNotification *)notification { NSControl *control = [notification object]; NSView *cellView = [control superview]; NSInteger tableRow = [keyTable rowForView:cellView]; NSString *cellText = [control stringValue]; [keysList replaceObjectAtIndex:tableRow withObject:cellText]; }I got this from Technical Q&A QA1551. The table cell's field editor sends the notification when the user finishes editing (tabs out, clicks elsewhere, hits return).
Topic: UI Frameworks SubTopic: AppKit Tags:
Jul ’15
Reply to NSBrowser....conditionally suppress right-click menu
I guess menuForEvent: must get called on a subview of NSBrowser, and it must eat it. There doesn't seem to be a clean way to handle this. I can override menuForEvent: on a NSMatrix subclass, if I set a custom matrix class..though that API is deprecated.What I want to do, is when a user right-clicks, and no column/row is selected, I want nothing to happen (no menu to show). I can be a bit hacky by using validateMenuItem: and hiding everything in there. Doing this isn't great either, because I can right click in a different column than the selected column and the menu will show...since I don't have the NSEvent to check the location of the click against, it seems that I have to add another layer of nasty code by converting the current cursor's position. None of this feels clean.Edit: Seems that I can set the menu property on each cell in browser:willDisplayCell:atRow:column:Far as handling right clicks in blank areas and showing an alternative menu depening on what that column
Topic: UI Frameworks SubTopic: AppKit Tags:
Jul ’15
Reply to NSBrowser....conditionally suppress right-click menu
Yeah, the getter for menu gets called from the addColumn method. It seems that everytime NSBrowser adds a column, it sets the menu for that column (whatever view it uses for the column) to be its menu. The main view used to create each column, far as I can tell is private API.What I'm going to try is:1) Setting the menu directly for each cell.2), Setting a different menu for the browser.3) Take hack-ish measures to validate the browser's menu to block it from being shown by hiding all the menu items when necessary.If there is a more elegant way to this, I'd love to know.
Topic: UI Frameworks SubTopic: AppKit Tags:
Jul ’15
Table columns - selection issues
While I can programatically select columns, there is no color change. Rows work fine once NSTableView.selectionHighLightStyle is set.I tried to implement my own solution but cannot change the font color (to white) in the column header to mimic column selection. Theheader background changes color fine. Same issue with the newest Xcode beta. Any suggestions?
0
0
354
Jul ’15