• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Solved: Cells within cells part 2
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Prev by Date: Print Settings
  • Next by Date: Loading nib in a dynamically loaded bundle
  • Previous by thread: Print Settings
  • Next by thread: Loading nib in a dynamically loaded bundle
  • Index(es):
    • Date
    • Thread