[Top][All Lists]

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

Setting checkbox with keyboard

From: Andreas Höschler
Subject: Setting checkbox with keyboard
Date: Mon, 19 Nov 2007 14:31:18 +0100

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;


and expected acceptsFirstResponder to be called when I try to tab into the column. However, this does not happen under GNUstep!?

When tabbing into the checkbox column on MacOSX the following method is called with an NSCBBoolean as anObject. However, the state of he boolean is always false whether the checkbox was set with the mouse before or not!?

- (void)tableView:(NSTableView *)aTableView setObjectValue:anObject forTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex

Any idea what I am missing?



reply via email to

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