How to detect when NSTextField has the focus or is it's content selected cocoa

后端 未结 4 363
天命终不由人
天命终不由人 2020-12-16 22:56

I have a NSTextField inside of a NSTableCellView, and I want an event which informs me when my NSTextField has got the focus for disabling several buttons, I found this meth

4条回答
  •  天命终不由人
    2020-12-16 23:58

    Just in case, as a slight variation over the idea of @sam, we can observe NSWindow.firstResponder property itself, it's KVO-compliant according to the documentation. Then compare it with textField or textField.currentEditor() to figure out whether the field is focused.

提交回复
热议问题