当用户直接单击NStableCellVIEw时,该行会正确突出显示.但是当用户单击NStableCellVIEw内的NSTextVIEw时,该行不会突出显示.
如何将NSTextVIEw上的单击传递给NStableCellVIEw以使该行突出显示?
类层次结构如下所示:
NSScrollVIEw> NStableVIEw> NStableColumn> NStableCellVIEw> NSTextVIEw
- (voID)mouseDown:(NSEvent *)theEvent{ // Notify delegate that this text vIEw was clicked and then // handled the click natively as well. [[self myTextVIEwDelegate] dIDClickMyTextVIEw:self]; [super mouseDown:theEvent];}
我正在重用NSTextVIEw的标准委托……
- (ID<MyTextVIEwDelegate>)myTextVIEwDelegate{ // See the following for info on formal protocols: // stackoverflow.com/questions/4635845/how-to-add-a-method-to-an-existing-protocol-in-cocoa if ([self.delegate conformstoprotocol:@protocol(MyTextVIEwDelegate)]) { return (ID<MyTextVIEwDelegate>)self.delegate; } return nil;}
在标题中……
@protocol MyTextVIEwDelegate <NSTextVIEwDelegate>- (voID)dIDClickMyTextVIEw:(ID)sender;@end
在委托中,我实现了dIDClickMyTextVIEw:来选择行.
- (voID)dIDClickMyTextVIEw:(ID)sender{ // User clicked a text vIEw. Select its underlying row. [self.tableVIEw selectRowIndexes:[NSIndexSet indexSetWithIndex:[self.tableVIEw rowForVIEw:sender]] byExtendingSelection:NO];}总结
以上是内存溢出为你收集整理的cocoa – 如何在NSTableCellView中单击NSTextView时在NSTableView中选择一行?全部内容,希望文章能够帮你解决cocoa – 如何在NSTableCellView中单击NSTextView时在NSTableView中选择一行?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)