editing text part in a custom NSTextFieldCell (of a NSTableView)
editing text part in a custom NSTextFieldCell (of a NSTableView)
- Subject: editing text part in a custom NSTextFieldCell (of a NSTableView)
- From: Nick Rogers <email@hidden>
- Date: Sat, 17 Aug 2013 22:01:39 +0530
Hi,
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
Any suggestions?
Wishes,
Nick
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden