Setting checkbox with keyboard

  • 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!?

    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?

    Thanks,

      Andreas
  • 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!?
    >
    > 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?

    If setting the state of the checkbox with the keyboard is not possible
    (right now) it would already help a lot if one were able to tab ove
    rthe checkbox column. Right now, tabbing ends when the checkbox column
    is reached which is very annoying for the user. Any idea how to avoid
    that? The tableview should just select the next editable cell behind
    the checkbox column for editing.

    Thanks a lot!

    Regards,

      Andreas
previous month november 2007 next month
MTWTFSS
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30    
Go to today