highlightling custom table header cell on mouse clicks
highlightling custom table header cell on mouse clicks
- Subject: highlightling custom table header cell on mouse clicks
- From: Ken Victor <email@hidden>
- Date: Sat, 11 Feb 2006 18:12:35 -0800
like many before me, i wish to enable various text sizes, etc. in the
headers of my NSTableView. i have my subclass of NSTableHeaderCell
working in all but one case:
when the user clicks on a header cell, i have the table's delegate
method (tableView:mouseDownInHeaderOfTableColumn:) call [[tableColumn
headerCell] setCellAttribute: NSCellHighlighted to: YES]. then in my
override of drawWithFrame:inView: (in my subclass of
NSTableHeaderCell) i draw the cell appropriately based on whether or
not its highlighted, whether or not its the current sort column, and
whether or not its window is the key window. after drawing the cell i
set it to be not highlighted (ie, [self setCellAttribute:
NSCellHighlighted to: NO]).
the situation in which this fails is when the user clicks in the
header, moves the mouse vertically out of the header cell (and the
cell unhighlights) and then moves the mouse back into the header cell
(without letting up the mouse button). at this time the header cell
should again highlight. but of course, my table's delegate method is
not called again and thus the header cell doesn't (re-)highlight. in
looking at the stack trace (see below) for this situation, i don't
see how to easily hook into this situation, as all i see on the stack
are private methods. nor do i see a different easy way to obtain this
behavior. is it really necessary to provide a subclass of
NSTableHeaderView and do all mouse tracking myself to really get the
proper behavior? ie, i would have to detect clicks, drag starts, etc.
from the archives (which have helped me to get this far) i see
several (lots of) people have desired to provide similar behavior.
has anyone solved this specific problem? and if so, can you tell me
how you did it?
thanx for any help/pointers/suggestions/etc.,
ken
#0 -[EntityTableHeaderCell drawWithFrame:inView:] (self=0x11e6b90,
_cmd=0x90a1095c, cellFrame={origin = {x = 63, y = 0}, size = {width =
213, height = 17}}, controlView=0x11e56a0) at
/Volumes/Disk2/Contracts/Accounts/code/Source/Controllers/Controls/EntityTableHeaderCell.mm:121
#1 0x937e55f0 in -[NSTableHeaderView
_drawHeaderCell:withFrame:withStateFromColumn:] ()
#2 0x937e4e70 in -[NSTableHeaderView _drawHeaderOfColumn:] ()
#3 0x937e4cd8 in -[NSTableHeaderView _drawColumnHeaderRange:] ()
#4 0x937e476c in -[NSTableHeaderView drawRect:] ()
#5 0x936d1e78 in -[NSView _drawRect:clip:] ()
#6 0x936d0c1c in -[NSView
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
()
#7 0x936d0fc8 in -[NSView
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
()
#8 0x936d0fc8 in -[NSView
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
()
#9 0x936d0fc8 in -[NSView
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
()
#10 0x936d0fc8 in -[NSView
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
()
#11 0x936f1664 in -[NSThemeFrame
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
()
#12 0x936ca674 in -[NSView
_displayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:]
()
#13 0x936bf968 in -[NSView displayIfNeeded] ()
#14 0x936bf7d8 in -[NSWindow displayIfNeeded] ()
#15 0x936bf684 in _handleWindowNeedsDisplay ()
#16 0x9075ccd8 in __CFRunLoopDoObservers ()
#17 0x9075cf78 in __CFRunLoopRun ()
#18 0x9075ca18 in CFRunLoopRunSpecific ()
#19 0x9318e1e0 in RunCurrentEventLoopInMode ()
#20 0x9318d7ec in ReceiveNextEventCommon ()
#21 0x9318d6e0 in BlockUntilNextEventMatchingListInMode ()
#22 0x9368c104 in _DPSNextEvent ()
#23 0x9368bdc8 in -[NSApplication
nextEventMatchingMask:untilDate:inMode:dequeue:] ()
#24 0x93a74ec0 in -[NSTableHeaderView
_trackAndModifySelectionWithEvent:onColumn:stopOnReorderGesture:] ()
#25 0x93a7692c in -[NSTableHeaderView mouseDown:] ()
#26 0x936e7eb0 in -[NSWindow sendEvent:] ()
#27 0x93690ef4 in -[NSApplication sendEvent:] ()
#28 0x00034244 in -[AccountsApp sendEvent:] (self=0x11258c0,
_cmd=0x90a2cdcc, theEvent=0x5f119b0) at
/Volumes/Disk2/Contracts/Accounts/code/Source/Accounts
Classes/AccountsApp.mm:239
#29 0x93688330 in -[NSApplication run] ()
#30 0x93778e68 in NSApplicationMain ()
#31 0x000030c8 in main (argc=1, argv=0xbffffa08) at
/Volumes/Disk2/Contracts/Accounts/code/Source/main.m:13
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden