Solved: Cells within cells part 2
Solved: Cells within cells part 2
- Subject: Solved: Cells within cells part 2
- From: Pete Yandell <email@hidden>
- Date: Mon, 28 Jul 2003 19:44:37 +1000
Thanks to Shaun Wexler for the solution.
By subclassing NSTextFieldCell and changing the drawWithFrame:inView:
method to draw the enclosed button cell and then call [super
drawWithFrame:inView:] with a modified frame, I get the behaviour I
want fairly cheaply.
I can then override the
selectWithFrame:inView:editor:delegate:start:length: as follows:
- (void)selectWithFrame:(NSRect)frame inView:(NSView*)controlView
editor:(NSText*)editor delegate:(id)delegate start:(int)selStart
length:(int)selLength
{
NSEvent* event = [[NSApplication sharedApplication] currentEvent];
NSPoint locationInWindow = [event locationInWindow];
NSPoint locationInView = [controlView convertPoint:locationInWindow
fromView:nil];
// This just works out where the text is drawn within my cell
NSRect textFrame = [self textFrameForCellFrame:frame];
if (NSPointInRect (locationInView, textFrame)) {
[super selectWithFrame:textFrame inView:controlView
editor:editor delegate:delegate start:selStart length:selLength];
}
}
Stay tuned for Cells within cells part 3...I've got one more tricky
problem left to solve. :)
Pete Yandell
http://pete.yandell.com/
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.