Skip navigation.
 
mlSimulate UpArrowKey with 8-key
FROM : Johan Augustsson
DATE : Wed Apr 04 14:54:25 2007

Hi

What is wrong with the following implementation of my NSBrowser
subclass?

- (void)keyDown:(NSEvent *)theEvent {
   int selectedColumn = [self selectedColumn]-1;
   int selectedRow = [self selectedRowInColumn:selectedColumn];

   NSLog(@"Key %d", [theEvent keyCode]);
   NSLog(@"Row %d, Col %d", selectedRow, selectedColumn);

   if([theEvent keyCode]==91 && (selectedRow>0))    //8
       [self selectRow:selectedRow-1 inColumn:selectedColumn];
}

My intention is to simulate an uparrowkey press when the user press
8. The first press of 8 makes the browser change line, but
NSBrowser's delegate methods are not called. The second and further
presses of 8 makes nothing and the browser's selected row and column
is -1.

What is wrong in this code? Does it exists a better solution? Can I
in my keyDown function simulate an upArrowKey? I tried with
performKeyEquivalent, but that did nothing. Perhaps I created the
event wrong.

Related mailsAuthorDate
No related mails found.