nscell

How to create a NSTextFieldCell, that in edit mode displays a custom view instead of NSTextField?

╄→尐↘猪︶ㄣ 提交于 2019-12-04 17:28:32
I have a tableView, with 3 columns containing NSTextFieldCell. Everything is populated with bindings. The text of the cells of one of the column is computed and is not editable directly. For this column, I would like when the cell goes into edit mode , to display a button or a custom view instead of the textField . Said in an other way, I want an NSCell that is a NSTextFieldCell when not being edited, and a NSButtonCell (or a custom view) when being edited. Any hint to move on to this? Here is what I tried, without success: Try #1 : I subclassed a NSTextFieldCell and override

NSCell vs NSView: when many controls are needed

*爱你&永不变心* 提交于 2019-12-04 13:07:50
I am aware that Apple is deprecating the use of NSCell in favour of NSView (see AppKit 10.10 release notes). It was previously recommended that NSCell be used for performance reasons when many controls were needed. I have spent considerable time implementing a custom control that required many subViews and the performance using NSView-type subViews was not good. See related stackoverflow discussion What are the practical limits in terms of number of NSView-type instances you can have in a window? I was struggling with 1000-2000 in-memory objects (which doesn't seem a lot). What is the actual

NSTextFieldCell with Multiple Lines

半世苍凉 提交于 2019-12-04 07:39:56
I need to show an NSTextFieldCell with multiple lines with different format on each line. Something like this: Line 1: Title Line 2: Description I subclassed NSTextFieldCell but I don't know how to go on with it. Any ideas? NSGod First off, you don't have to subclass NSTextFieldCell to achieve this, since, as a subclass of NSCell , NSTextFieldCell inherits -setAttributedStringValue: . The string you provided can be represented as a NSAttributedString . The following code illustrates how you could achieve the desired text with an ordinary NSTextField . MDAppController.h: @interface

NSCell Custom Highlight

ぐ巨炮叔叔 提交于 2019-12-03 13:36:58
问题 I'm trying to subclass NSCell to draw a custom background highlight. The documentation seems to suggest that the overriding highlight:withFrame:inView: should allow me to do this but the method is never called. Instead, I've overridden drawInteriorWithFrame:inView: which works fine - I can draw what I want in the cell. However, the issue is that I have to draw everything myself, losing the functionality of the type of NSCell I am extending - for example an NSTextFieldCell's ability to display

NSCell Custom Highlight

点点圈 提交于 2019-12-03 04:41:22
I'm trying to subclass NSCell to draw a custom background highlight. The documentation seems to suggest that the overriding highlight:withFrame:inView: should allow me to do this but the method is never called. Instead, I've overridden drawInteriorWithFrame:inView: which works fine - I can draw what I want in the cell. However, the issue is that I have to draw everything myself, losing the functionality of the type of NSCell I am extending - for example an NSTextFieldCell's ability to display text: Custom drawn highlighted cell: However, I just want to redraw the background (the highlight),

In OS X 10.10, can I implement an NSControl without an NSCell?

丶灬走出姿态 提交于 2019-12-03 03:57:44
I am learning about NSControl . I am aware that NSCell has begun its road to deprecation in OS X 10.10 Yosemite, and so I'd rather not use an API that is going away. Also, the NSControl Class Reference shows all cell accessors have been deprecated. I understand all this, but what is not as clear is what the recommended course is for people writing NSControl subclasses on 10.10. All of the Apple guides on the subject make no mention of the deprecation of NSCell . I suppose I could just do things the old way, but then I'd need to change my code when Apple advances the deprecation of NSCell to

NSTextFieldCell's cellSizeForBounds: doesn't match wrapping behavior?

╄→гoц情女王★ 提交于 2019-12-01 14:01:57
It seems to be commonly accepted that cellSizeForBounds: allows one to calculate a text field's "natural" size. However, for NSTextField, I've found that it doesn't quite match: @interface MyTextField : NSTextField @end @implementation MyTextField - (void)textDidChange:(NSNotification *)notification { [super textDidChange:notification]; [self validateEditing]; // Forces updating from the field editor NSSize cellSize = [self.cell cellSizeForBounds: NSMakeRect(0, 0, self.bounds.size.width, CGFLOAT_MAX)]; NSRect frame = self.frame; CGFloat heightDelta = cellSize.height - frame.size.height; frame

NSOutlineView Changing disclosure Image

假如想象 提交于 2019-11-30 07:37:50
I my outline view, i am adding Custom cell, To drawing custom cell, i am referring example code , present in the Cocoa documentation http://www.martinkahr.com/2007/05/04/nscell-image-and-text-sample/ I want to change the disclosure image of the cell with my custom image, i have tried following things - (void)outlineView:(NSOutlineView *)outlineView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item { if([item isKindOfClass:[NSValue class]]) { MyData *pDt = (MyData *)[item pointerValue]; if(pDt->isGroupElement()) { [cell setImage:pGroupImage]; } } } but that too

How to setup a NSTableView with a custom cell using a subview

社会主义新天地 提交于 2019-11-29 17:23:35
I am trying to setup a NSTableView with a custom cell using an ArrayController and Bindings . To accomplish this I added a subview to the custom cell. The data connection seems to work somewhat. Though, there seems to be a redraw problem which I cannot fix. When I load the application only some of the cells are rendered. When I scroll through the rows or select one the rendering changes. I created an example project on github to illustrate what the problem is. The actual source code for the cell rendering can be found here : // CustomCell.m - (void)drawInteriorWithFrame:(NSRect)cellFrame

NSOutlineView Changing disclosure Image

巧了我就是萌 提交于 2019-11-29 10:15:36
问题 I my outline view, i am adding Custom cell, To drawing custom cell, i am referring example code , present in the Cocoa documentation http://www.martinkahr.com/2007/05/04/nscell-image-and-text-sample/ I want to change the disclosure image of the cell with my custom image, i have tried following things - (void)outlineView:(NSOutlineView *)outlineView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item { if([item isKindOfClass:[NSValue class]]) { MyData *pDt =