macos – NSTableView命中选项卡在编辑时从一行跳到另一行

macos – NSTableView命中选项卡在编辑时从一行跳到另一行,第1张

概述我有一个NSTableView.在编辑时,如果我点击标签,它会自动跳转到下一列.这太棒了,但是当我在最后一栏编辑字段并点击标签时,我想要专注于跳转到NEXT行的第一列. 有什么建议? 感谢迈克尔的起始代码,它非常接近最终的工作!这是我使用的最终代码,希望它对其他人有帮助: - (void) textDidEndEditing: (NSNotification *) notification { 我有一个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];    }}
解决方法 子类UItableVIEw并添加代码以捕获textDIDEndEditing调用.

然后,您可以根据以下内容决定做什么:

- (voID) textDIDEndEditing: (NSNotification *) notification{    NSDictionary *userInfo = [notification userInfo];    int textMovement = [[userInfo valueForKey:@"NSTextMovement"] intValue];    if ([self selectedColumn] == ([[self tableColumns] count] - 1))        (textMovement == NSTabTextMovement)    {        // the tab key was hit while in the last column,// so go to the left most cell in the next row        [yourtableVIEw editColumn: 0 row: ([self selectedRow] + 1)  withEvent: nil select: YES];    }    [super textDIDEndEditing: notification];    [[self window] makeFirstResponder:self];} // textDIDEndEditing

此代码未经过测试……没有保修……等等.您可能需要将[super textDIDEndEditing:]调用移动到最右侧单元格中的选项卡.但希望这会帮助你走到终点.让我知道!

总结

以上是内存溢出为你收集整理的macos – NSTableView命中选项卡在编辑时从一行跳到另一行全部内容,希望文章能够帮你解决macos – NSTableView命中选项卡在编辑时从一行跳到另一行所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1011740.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-22
下一篇 2022-05-22

发表评论

登录后才能评论

评论列表(0条)

保存