Button in textfieldcell inside a table (SOLVED)

Christiaan Hofman cmhofman at gmail.com
Tue Dec 11 14:38:35 PST 2007


On 11 Dec 2007, at 10:58 PM, Benjamin Stiglitz wrote:

>> I was doing this by using an NSTextFieldCell subclass, overriding -
>> drawRect: and -trackMouse:inRect:ofView:untilMouseUp:. This was
>> working fine on Tiger. However on Leopard -trackMouse:... is not
>> called anymore on a mouseDown:, so this approach completely fails.
>>
>> Does anyone on this list have an alternative for doing this, that
>> works both on Tiger and Leopard?
>
> On Leopard you can implement this delegate method to enable the  
> cell tracking method to be called:
> - (BOOL)tableView:(NSTableView *)tableView shouldTrackCell:(NSCell  
> *)cell forTableColumn:(NSTableColumn *)tableColumnrow:(NSInteger)row
>
> See the NSTableView documentation:
> http://developer.apple.com/documentation/Cocoa/Reference/ 
> ApplicationKit/Classes/NSTableView_Class/Reference/Reference.html#// 
> apple_ref/occ/instm/NSObject/ 
> tableView:shouldTrackCell:forTableColumn:row:
>
> -Ben


That would not do what we want, as it contains only enough  
information to determine the cell, not the location in the cell (it  
should only track for the button inside the text cell). However we  
found that implementing -hitTestForEvent:inRect:ofView: in the  
NSTextFieldCell subclass does the trick.

Christiaan



More information about the MacOSX-dev mailing list