[Top][All Lists]

[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 23:08:03 +0100
User-agent: Thunderbird (X11/20070801)

Andreas Höschler wrote:
> Hoi,
>> 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?
> I expect anObject in
> - (void)tableView:(NSTableView *)aTableView setObjectValue:anObject
> forTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex
> {
> }
> to be [NSNumber numberWithInt:1] when the checkbox is checked and either
> [NSNumber numberWithInt:0] or nil when the checkbox is dechecked. On
> GNUstep I get an NSString that can be interpreted like an NSNumber, on
> the Mac I get an NSCFBoolean instance. I suppose this is an NSNumber
> sublcass. Whatever it is, I need to be able to decide in the above
> method whether the checkbox got checked or dechecked. This works on both
> platforms for mouseclicks. But it works on neither platform for key
> events. On the Mac I get an NSCFBoolean (true) when on the switch cell
> and pressing the space bar. Good so far. However, when I tab into the
> checkbox column with a previously set checkbox, then
> - (void)tableView:(NSTableView *)aTableView setObjectValue:anObject
> forTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex
> is called with NSCFBoolean (false). I consider this is a bug in Cocoa.
> On GNUstep I currently cannot even tab into the checkbox column. It
> would be great if we could get something sorted out in GNUstep that is
> not correctly implemented in GNUstep. :-)
>> 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.
> What exactly do you want me to test?
All of the above :-)

> Until this has been sorted out correctly it would already help a lot, if
> the not selectable checkbox column was simply jumped over when tabbing
> through the row. Currently editing of the row (cells) stops when the
> checkbox column is reached which is not appreciated by users. :-)

If you want just that, make the checkbox not editable or let your
delegate report it as not editable ([_delegate tableView: self
shouldEditTableColumn: tableColumn row: rowIndex])


reply via email to

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