Skip navigation.
 
mlRe: Implementing a Slightly Unusual NSTableView
FROM : Graham Cox
DATE : Sun Apr 20 11:28:11 2008

Hi Peter,

You'll note my code says nothing about first responder, so you should 
get whatever the table view is set to do. In my use of this code, my 
table view is actually in a floating window and I've set it only to 
become key if needed - and so for changing selection or toggling 
checkboxes, it doesn't.

Your situation sounds a bit different so I haven't tested for it, but 
note that for all other columns, I call [super mouseDown:...] so I 
would think that you should get completely normal behaviour for these 
columns.

I think what you're saying is that the view is focused before you get 
the mouseDown: passed to you, so it focuses the table before you get a 
chance to handle the checkbox (and prevent focusing). That being the 
case you could turn the problem on its head - set the table view to 
refuse first responder generally, then in the mouseDown: method 
deliberately make it the first responder if the mouse hits any of the 
other columns. No idea if this will work, but worth a try?

As an aside: I also use this code for a simple UI to a drawing 
program's layers - I found that letting the table grab focus unless 
it's actually editing the layer's name exceedingly annoying - it takes 
focus away from the drawing content view itself, which gets old very 
fast. So setting the table to never accept focus (unless editing) is 
much more usable, I found. If you still want a decent strong highlight 
for the selected layer rather than a washed-out grey then you can 
override other bits of the table view to draw it however you want.

G.


On 20 Apr 2008, at 5:06 pm, Peter Zegelin wrote:
> Hi Graham,
>
>     This is great - worked like a charm first time. Many, many thanks!
>
> The only thing I think I need to do now is to get the TableView to 
> become first responder when I don't click on a checkbox. I think I'm 
> nearly there as well. What I have done is make the tableview accept 
> firstResponder and then added:
>
> [[self window] makeFirstResponder:nil];
>
> in the mousDown of the TableView - just before I begin tracking the 
> cell. This prevents the tableView from becoming first responder 
> unless I click on a normal column. Only problem of course is that 
> the view that *was* the first responder now loses the focus. I tried:
>
> [[self window] makeFirstResponder: [[self window] firstResponder]];
>
> to see if I could set the firstResponder back to what it was, but by 
> the time I've clicked on the table it is already the first responder.
>
> Any suggestions how I could prevent my table from becoming first 
> responder when I click on a checkbox using your code?
>
> thanks again for your help,
>
> Peter
>

Related mailsAuthorDate
mlImplementing a Slightly Unusual NSTableView Peter Zegelin Apr 19, 12:05
mlRe: Implementing a Slightly Unusual NSTableView Jens Alfke Apr 19, 17:29
mlRe: Implementing a Slightly Unusual NSTableView Graham Cox Apr 20, 03:04
mlRe: Implementing a Slightly Unusual NSTableView Peter Zegelin Apr 20, 09:06
mlRe: Implementing a Slightly Unusual NSTableView Graham Cox Apr 20, 11:28
mlRe: Implementing a Slightly Unusual NSTableView Peter Zegelin Apr 20, 12:51
mlRe: Implementing a Slightly Unusual NSTableView Graham Cox Apr 20, 16:36
mlRe: Implementing a Slightly Unusual NSTableView Peter Zegelin Apr 21, 12:16
mlRe: Implementing a Slightly Unusual NSTableView Corbin Dunn Apr 21, 19:08