On Aug 17, 2013, at 10:31 AM, Nick Rogers wrote:
> I have a NSTableView and I'm setting a particular column to have a custom
> NSTextFieldCell subclass object as its cell.
>
> For this I'm doing in awakeFromNib:
> TableViewListCell *aTableViewListCell3 = [[[TableViewListCell alloc] init]
> autorelease];
> [[tableViewPresetsMainList tableColumnWithIdentifier:COLUMN_ID_DESC]
> setDataCell:aTableViewListCell3];
> [[[tableViewPresetsMainList tableColumnWithIdentifier:COLUMN_ID_DESC]
> dataCell] setEditable:YES];
>
> The object value returned for this cell in method, -
> (id)tableView:(NSTableView *)aTableView
> objectValueForTableColumn:(NSTableColumn *)aTableColumn
> row:(NSInteger)rowIndex, is a NSMutableDictionary containing the text to
> display in the cell as well an NSImage object to display in the cell.
>
> Then in NSTextFieldCell subclass "TableViewListCell", in method, -
> (void)drawInteriorWithFrame:(NSRect)theCellFrame inView:(NSView
> *)theControlView, I'm drawing the image (32x32 pixels) and then text to the
> right side of image, after obtaining these image and text from the cell's
> objectValue, which is the NSMutableDictionary.
>
> Now the problem is that when I click on the cell for editing the text
> displayed, the field that pops up shows the value same as description of the
> mutable dictionary.
> e.g.
> {
> Description = "Preset #0";
> Icon = "<NSImage 0x1001a3ab0 Name=Presets Size={32, 32} Reps=(\n
> \"NSBitmapImageRep 0x1001f75e0 Size={32, 32} ColorSpace=Device RGB colorspace
> BPS=8 BPP=32 Pixels=32x32 Alpha=YES Planar=NO Format=2
> CurrentBacking=<CGImageRef: 0x1001f76f0> CGImageSource=0x1005a48e0\"\n)>";
> }
>
> Whereas I want to show and edit only the drawn name "Preset #0",.
>
> Also I want to set the editing field's rect to a smaller one, which I guess I
> can do by over-riding the method, - (void)editWithFrame:(NSRect)aRect
> inView:(NSView*)controlView editor:(NSText*)textObj delegate:(id)anObject
> event:(NSEvent*)theEvent
Use a view-baed NSTableView instead. You won't even have to have an
NSTextFieldCell subclass, and you might even be able to use a vanilla
NSTableCellView. It's actually a better approach to your overall table issue,
IMHO.
HTH,
Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"
_______________________________________________
Cocoa-dev mailing list ([email protected])
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]