FROM : Peter Zegelin
DATE : Mon Apr 21 12:16:38 2008
Thanks Graham - I have updated my code as well.
I also think I solved the focus problem. Tried most of the responder
methods without luck so I took a different tack. I realized that I
would only have 3 views that could grab the focus so I created a
global variable 'currentResponder' (will make it local to the window
when I figure out how) and set it in becomeFirstResponder of the other
views. Then in my 'special' tableview if I am clicking on a checkbox I
just call:
[[self window] makeFirstResponder: currentResponder];
to set the focus back to the original view. Works like a treat even if
it seems a bit of a hack.
regards,
Peter
www.fracturedSoftware.com
On 21/04/2008, at 12:36 AM, Graham Cox wrote:
> I just noticed a bug in the code I posted - it should be:
>
> - mouseDown:
> ...
>
> if ([dataCell trackMouse:event inRect:cellFrame ofView:self
> untilMouseUp:YES])
> {
> // call the datasource to handle the checkbox state change as normal
> [[self dataSource] tableView:self setObjectValue:[dataCell
> objectValue] forTableColumn:theColumn row:row];
> }
> ...
>
>
> previously I passed dataCell directly, not [datacell objectValue],
> and I passed it to the delegate, not the dataSource.
>
> In fact passing <dataCell> works with many cell types such as
> buttons and checkboxes because they happen to implement methods such
> as stringValue and so on, but if you use a custom cell that returns
> something like a colour for example, that doesn't work. The delegate/
> datasource mixup is another thing I got away with as usually they
> happen to be the same.
>
> To be honest I'm having to sort of guess how the tableview is
> actually calling its dataSource, so this could still be wrong, but
> so far this handles all the cases I've thrown at it (admittedly not
> that many, but includes a variety of standard and custom cells).
>
> G.
DATE : Mon Apr 21 12:16:38 2008
Thanks Graham - I have updated my code as well.
I also think I solved the focus problem. Tried most of the responder
methods without luck so I took a different tack. I realized that I
would only have 3 views that could grab the focus so I created a
global variable 'currentResponder' (will make it local to the window
when I figure out how) and set it in becomeFirstResponder of the other
views. Then in my 'special' tableview if I am clicking on a checkbox I
just call:
[[self window] makeFirstResponder: currentResponder];
to set the focus back to the original view. Works like a treat even if
it seems a bit of a hack.
regards,
Peter
www.fracturedSoftware.com
On 21/04/2008, at 12:36 AM, Graham Cox wrote:
> I just noticed a bug in the code I posted - it should be:
>
> - mouseDown:
> ...
>
> if ([dataCell trackMouse:event inRect:cellFrame ofView:self
> untilMouseUp:YES])
> {
> // call the datasource to handle the checkbox state change as normal
> [[self dataSource] tableView:self setObjectValue:[dataCell
> objectValue] forTableColumn:theColumn row:row];
> }
> ...
>
>
> previously I passed dataCell directly, not [datacell objectValue],
> and I passed it to the delegate, not the dataSource.
>
> In fact passing <dataCell> works with many cell types such as
> buttons and checkboxes because they happen to implement methods such
> as stringValue and so on, but if you use a custom cell that returns
> something like a colour for example, that doesn't work. The delegate/
> datasource mixup is another thing I got away with as usually they
> happen to be the same.
>
> To be honest I'm having to sort of guess how the tableview is
> actually calling its dataSource, so this could still be wrong, but
> so far this handles all the cases I've thrown at it (admittedly not
> that many, but includes a variety of standard and custom cells).
>
> G.
| Related mails | Author | Date |
|---|---|---|
| Peter Zegelin | Apr 19, 12:05 | |
| Jens Alfke | Apr 19, 17:29 | |
| Graham Cox | Apr 20, 03:04 | |
| Peter Zegelin | Apr 20, 09:06 | |
| Graham Cox | Apr 20, 11:28 | |
| Peter Zegelin | Apr 20, 12:51 | |
| Graham Cox | Apr 20, 16:36 | |
| Peter Zegelin | Apr 21, 12:16 | |
| Corbin Dunn | Apr 21, 19:08 |






Cocoa mail archive

