nstableview

Custom drag image with NSTableView as drag source

耗尽温柔 提交于 2019-11-29 14:36:51
Is it necessary to subclass NSTableView or NSTableCellView to create a custom drag image when the tableView is the drag source? If not, what is the magic method I am missing to do this? I cannot seem to find anything solid. NSTableCellView subclasses have can (slightly mysteriously) override: @property(retain, readonly) NSArray *draggingImageComponents (array of NSDraggingImageComponent instances that will get composited together (who knows in what fashion they get composited...)) NSTableView itself has - (NSImage *)dragImageForRowsWithIndexes:(NSIndexSet *)dragRows tableColumns:(NSArray *

View-based NSOutlineView without NIB?

不想你离开。 提交于 2019-11-29 14:28:59
问题 NSOutlineView is a subclass of NSTableView . And currently, NSTableView supports two implementations. Cell-based. View-based. To make OSX 10.8 Finder style side bar ( with automatic gray Icon styling ), need to use view-based table view with source-list highlight style. With NIBs, this is typical job. Nothing hard. (see SidebarDemo) But I want to avoid any NIBs or Interface Builder. I want make the side bar purely programmatically. In this case, I have big problem. AFAIK, there's no way to

Fixed Height NSTableView, Avoid Scrolling

≡放荡痞女 提交于 2019-11-29 10:45:23
I have an NSTableView that has a very small fixed number of rows. When I create an NSTableView in Interface Builder, the NSTableView is contained within an NSScrollView . I have not found a way to make the table exist outside the context of a scroll view. Since the table only has a small number of rows, I don't want it to scroll. I want the table to resize based on the number of rows, and I want the bottom border immediately under the bottom of the last row. If I set the height of the scroll view as follows, I get a vertical scroll bar: height = (numRows * (rowHeight + intercellSpacingHeight))

Print the NSTableView's row number of the row clicked by the user

余生颓废 提交于 2019-11-29 09:31:35
I have a NSTableView with one column. I would like to print the row number of the row that the user has clicked on. I am not sure where I should start with this. Is there a method for this? You can use the selectedRowIndexes property from the tableView in the tableViewSelectionDidChange method in your NSTableView delegate. In this example, the tableView allows multiple selection. Swift 3 func tableViewSelectionDidChange(_ notification: Notification) { if let myTable = notification.object as? NSTableView { // we create an [Int] array from the index set let selected = myTable.selectedRowIndexes

Handling custom selection style in view based NSTableView

强颜欢笑 提交于 2019-11-29 07:54:14
How do I go about drawing my own custom selection style for a view based NSTableView ? I tried putting a BOOL var in my NSTableCellView subclass and set that to YES if it is clicked and then I can successfully draw my custom selection. But how do I change that BOOL var to NO when another view is clicked? Thanks for any help. EDIT: After reading through the NSTableView docs, it looks like I need to subclass NSTableRowView to override the selection drawing, but what do I do with my NSTableRowView subclass? How do I get the table to use it? Alright, I figured it out. You just have to subclass

Create a custom cell in a NSTableView

蓝咒 提交于 2019-11-29 07:53:11
问题 In my app I'm trying to create a custom cell like the follow: I know how to do that with iOS and I guess it should be quite the same by using OS X. So in interface builder I designed the table view but I can figure how to create a custom cell. I tried to insert in the .xib in which I designed the table view the custom component I need (2 NSTextField and 2 NSImageView ), then I create a class "CustomCell.m" and "CustomCell.h" as subclass of NSTableCellView , so I tried to connect my component

Create view based NSTableView programmatically using Bindings in Swift

馋奶兔 提交于 2019-11-29 07:52:31
I am working through a Cocoa in Swift book and I am stuck in a chapter on Bindings. The book uses nib files but I want to do everything programmatically (since I am joining a team that does not use nibs). The project is to create a view based table with 2 columns and the content of the table is bound to the arrangedObjects of an array controller. The array controller's content is bound to an array of Employee objects (Employee has 2 properties viz. name and salary). I was able to create the table programmatically like below (one scroll view, one table view, 2 table columns): let tableWidth =

NSTableView Right Clicked Row Index

柔情痞子 提交于 2019-11-29 06:54:13
问题 I'm looking for a way to get right-clicked row index from NSTableView but I can't find any delegate methods or class attributes for it. Any suggestion is appreciated. 回答1: While I haven't done this, I am pretty sure you can by overriding NSView 's - (NSMenu*)menuForEvent:(NSEvent*)theEvent . The example in this link does a point conversion to determine the index. -(NSMenu*)menuForEvent:(NSEvent*)theEvent { NSPoint mousePoint = [self convertPoint:[theEvent locationInWindow] fromView:nil]; int

NSTableView Row Height based on NSStrings

試著忘記壹切 提交于 2019-11-29 04:43:29
Basically, I have an NSTableView with 1 collumn, and I'm inserting long strings into each row. However, not all the strings are long, so I'd like the height of each row to be different based on how long the string is. I've figured out that I need to ask the collumn how wide it is, and then ask the string how many lines it will take up if the collumn is that wide, and then decide how "tall" the NSCell will be. But how exactly do I go about doing that? I've gotten the collumn width from: [[[tableView tableColumns] objectAtIndex:0] width]; but I can't figure out how to ask the NSString how much

Hiding NSTableView header?

浪尽此生 提交于 2019-11-29 04:30:02
问题 How do I hide an NSTableView header completely, so that it does not take any space up? 回答1: In Interface Builder, select the table view, open the attributes inspector (alt-command-4), and uncheck the "Headers" checkbox in the "Columns" section. 回答2: You can also set the headerView programmatically without subclassing [tableView setHeaderView:nil]; 回答3: To do this programmatically, you can subclass NSTableView (or any NSTableView child class) and return nil for the headerView variable: