arelenas
arelenas

Reputation: 65

Detecting lost focus for NSTableView in Cocoa

Is there any way to detect and respond when a control on a window loses focus?

I want to run some code when a user leaves NSTableView.

Thanks,

Upvotes: 4

Views: 1066

Answers (1)

jscs
jscs

Reputation: 64002

You can do this in 10.6 and later by using KVO to observe the window's firstResponder. It will change when the focused control in the window changes.

Put the code you want to run in the observing object's observeValueForKeyPath:ofObject:change:context: method.

Upvotes: 3

Related Questions