Button in textfieldcell inside a table

  • Hi all,

    I'm trying to get a button inside a text cell in a tableview working
    on Leopard. A bit like the little Store arrow buttons in iTunes.

    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?

    Thanks,
    Christiaan
  • Hi all,

    I'm trying to get a button inside a text cell in a tableview working
    on Leopard. A bit like the little Store arrow buttons in iTunes.

    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?

    Thanks,
    Christiaan
  • > 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/Cla
    sses/NSTableView_Class/Reference/Reference.html#/

    /apple_ref/occ/instm/NSObject/
    tableView:shouldTrackCell:forTableColumn:row:

    -Ben
  • 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
previous month december 2007 next month
MTWTFSS
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31            
Go to today