Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
当窗口上的控件失去焦点时,有什么方法可以检测和响应?
我想在用户离开 NSTableView 时运行一些代码。
谢谢,
您可以在 10.6 及更高版本中执行此操作,方法是使用KVO观察窗口的firstResponder. 当窗口中的焦点控件发生变化时,它会发生变化。
firstResponder
将要运行的代码放入观察对象的observeValueForKeyPath:ofObject:change:context:方法中。
observeValueForKeyPath:ofObject:change:context: