如果用户在编辑 NSTextFieldCell 时输入了某些文本,我正在尝试将 NSTextFieldCell 的内容加粗。
到目前为止,我有这个:
在 awakeFromNib 中:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textFieldCellDidChange:) name:NSControlTextDidChangeNotification object:theNSTableView];
方法:
- (void) textFieldCellDidChange: (id) sender
{
//successfully captures contents of the NSTextFieldCell prior to the
//start of editing
NSString * textOfMyNSTextFieldCell = [myNSTextFieldCell stringValue];
//attempts to capture the current edited contents of the NSTextFieldCell while
//editing is still in progress:
//but DOES NOT YET WORK:
NSText *fieldEditor = [myTableView currentEditor];
textOfMyNSTextFieldCell = [fieldEditor string];
}
是否可以在编辑仍在进行时捕获 NSTextFieldCell 的编辑内容?