문제

Inside a NStableViewDelegate, I use a sheet window to begin a edit operation like this:

- (BOOL)tableView:(NSTableView *)aTableView shouldEditTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex {

    editEntity = [[contractsAC selectedObjects] objectAtIndex:0];
    needsWriteToArrayController = FALSE;

    [self beginSheet];

    return NO;

}

- (void) beginSheet {

  [NSApp beginSheet:contractEditWindow 
       modalForWindow:mainWindow 
        modalDelegate:nil 
       didEndSelector:NULL 
          contextInfo:nil
     ];

}

If I double-click a table cell, things behave as expected: The sheet appears and I'm able to edit its inputs.

If a table cell is selected and I press the return key, things tend to be wired: The sheet appears, but the return key event gets forwarded to the sheet. In turn, the default SAVE button of the sheet gets fired - and makes the sheet disappear. Too bad, no chance to edit ;-)

Should I consume the current key event inside the shouldEditTableColumn: method? If yes, how could I?

도움이 되었습니까?

해결책

You could try deferring sheet presentation with -performSelector:withObject:afterDelay:. Add a private method that sets up and presents the sheet, and give it a delay of 0.0. It'll be scheduled slightly later on the run loop, giving the keypress a chance to propagate.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top