discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Setting checkbox with keyboard


From: Fred Kiefer
Subject: Re: Setting checkbox with keyboard
Date: Mon, 19 Nov 2007 20:04:41 +0100
User-agent: Thunderbird 2.0.0.6 (X11/20070801)

Andreas Höschler wrote:
> Hi all,
> 
> I want to have a checkbox in a tableview and be able to tab into it
>> from the column to its left with the TAB key and then set its state 
> with the keyboard (e.g. the space key, any other would be fine as well).
> This is to avoid the need to use the mouse for very efficient data
> entry. I did
> 
>               NSButtonCell *buttonCell = [[NSButtonCell alloc]
> initTextCell:@""];
>               [buttonCell setButtonType:NSSwitchButton];
>               [buttonCell setImagePosition:NSImageOnly];
>               [buttonCell setSelectable:YES];
>               [buttonCell setEditable:YES];
>               [tableColumn setDataCell:buttonCell];
>               [_displayObjects addObject:buttonCell];
>               [buttonCell release];
> 
> This allows me to tab into and over the checkbox column on the Mac. This
> does not work under GNUstep! Why? I subclasses NSButtonCell
> 
> @implementation GSButtonCell
> 
> - (BOOL)acceptsFirstResponder
> {
>    BOOL result = [super acceptsFirstResponder];
>    NSLog(@"%@ acceptsFirstResponder %d", self, result);
>    return result;
> }
> 
> @end
> 
> and expected acceptsFirstResponder to be called when I try to tab into
> the column. However, this does not happen under GNUstep!?
> 

Is this method called under Cocoa? What GNUstep currently does when the
tab key is pressed is to check whether the next cell is editable and if
so the table view starts to edit that cell.
I agree that this is not the best behaviour. But what would be correct?
Check if the cell is selectable? Check the accepts first responder
state? And then just select the cell? Or edit it, if it is editable and
just select it if not? Your cell is editable. What sort of editing
behaviour do you expect from an NSSwitchButton?
And who would get the space key? Normally the NSButton turns that key
into a click. Should the table view do the same? If so for all cells or
only for specific ones?
For the correct behaviour we will need a lot of tests with Cocoa. If you
are willing to do this test and send in the result, it would be fairly
easy to implement the correct behaviour.

Cheers,
Fred




reply via email to

[Prev in Thread] Current Thread [Next in Thread]