Ken*_*and 5 macos cocoa focus nstableview first-responder
我有一个NSTableView.在编辑时,如果我点击标签,它会自动跳转到下一列.这太棒了,但是当我在最后一栏编辑字段并点击标签时,我想要专注于跳转到NEXT行的第一列.
有什么建议?
感谢迈克尔的起始代码,它非常接近最终的工作!这是我使用的最终代码,希望它对其他人有帮助:
- (void) textDidEndEditing: (NSNotification *) notification {
NSInteger editedColumn = [self editedColumn];
NSInteger editedRow = [self editedRow];
NSInteger lastColumn = [[self tableColumns] count] - 1;
NSDictionary *userInfo = [notification userInfo];
int textMovement = [[userInfo valueForKey:@"NSTextMovement"] intValue];
[super textDidEndEditing: notification];
if ( (editedColumn == lastColumn)
&& (textMovement == NSTabTextMovement)
&& editedRow < ([self numberOfRows] - 1)
)
{
// the tab key was hit while in the last column,
// so go to the left most cell in the next row
[self selectRowIndexes:[NSIndexSet indexSetWithIndex:(editedRow+1)] byExtendingSelection:NO];
[self editColumn: 0 row: (editedRow + 1) withEvent: nil select: YES];
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1904 次 |
| 最近记录: |