nstableview

Respond to mouse events in text field in view-based table view

独自空忆成欢 提交于 2019-11-27 18:22:31
I have text fields inside a custom view inside an NSOutlineView . Editing one of these cells requires a single click, a pause, and another single click. The first single click selects the table view row, and the second single click draws the cursor in the field. Double-clicking the cell, which lets you edit in a cell-based table view, only selects the row. The behavior I want: one click to change the selection and edit. What do I need to override to obtain this behavior? I've read some other posts: The NSTextField flyweight pattern wouldn't seem to apply to view-based table views, where the

NSTableView Row Height based on NSStrings

自闭症网瘾萝莉.ら 提交于 2019-11-27 16:46:22
问题 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: [[

Is it possible to design NSCell subclasses in Interface Builder?

守給你的承諾、 提交于 2019-11-27 11:15:42
问题 I'm trying to subclass NSCell for use in a NSTableView. The cell I want to create is fairly complicated so it would be very useful if I could design it in Interface Builder and then load the NSCell from a nib. Is this possible? How do I do it? 回答1: The question was about a subclass of NSCell; the other answers seem to be doing something else, likely taking advantage of UITableViewCell being a view. NSCell is not a view. While laying a custom cell out in IB would be a useful thing to be able

Change selection color on view-based NSTableView

风格不统一 提交于 2019-11-27 10:07:46
问题 Standard highlighting color in OS X applications is blue. Is it possible to change it to another color, e.g. gray? Note that I am using the new view-based NSTableView available starting from OS X 10.7. 回答1: Since you're using the view based NSTableView, you can subclass NSTableRowView, feed it to the table delegate method - (NSTableRowView *)tableView:(NSTableView *)tableView rowViewForRow:(NSInteger)row; , then customize your selection in the row view class. Here's an example: - (void

Double click an NSTableView row in Cocoa?

不想你离开。 提交于 2019-11-27 10:05:29
问题 I need my application to open a window when a user double clicks on a row in an NSTableView . I'm having a bit of a difficult time finding information or examples on how to accomplish this. Can anybody point me in the right direction? 回答1: Take a look at the -setDoubleAction: method on NSTableView; you can set that to a method that will be called just like the normal target-action system but on a double-click. In that action method, -clickedRow will be useful. 回答2: Adding more basic

NSTableView's viewForTableColumn:row: called for more rows than expected in Mavericks

眉间皱痕 提交于 2019-11-27 07:14:58
问题 My understanding was that viewForTableColumn:row: would be called only for rows that are visible. I confirmed this using the following: NSRange rowsInRect = [aTableView rowsInRect:[aTableView visibleRect]]; NSInteger lastVisibleRow = rowsInRect.location + rowsInRect.length; But with Mavericks, viewForTableColumn:row is getting called many more times without scrolling down. For example, if my last visible row was 35, data source method is called for 139 rows. Can anybody explain this? 回答1: I

NSTableView scrollRowToVisible with animation

眉间皱痕 提交于 2019-11-27 01:11:37
问题 I am trying to implement an action to scroll to the top of a NSTableView, and the bottom of the NSTableView. I am using scrollRowToVisible but I'd love the action to be animated. Is there a way to do this? 回答1: While the NSTableView does not have a scroll property you can directly animate, you can instead, with a bit of math animate the scrolling of the NSClipView that the NSTableView lives in. Here is how I did this (within a custom subclass of NSTableView) to smoothly animate the row at

Get all Users on OS X

浪尽此生 提交于 2019-11-26 21:27:16
问题 So I want to implement Parental Controls per user in my app, but I need a way of getting all Users and add them to an NSTableView. These users should be the same displayed by the Login Window, excluding the Other... one and system users. Any ideas on how to do this? Also, I want to be able to get the selection on that table view and of course change the settings displayed according to that. 回答1: Here's how I do it: #import <CoreServices/CoreServices.h> #import <Collaboration/Collaboration.h>