NSTextField not calling delegate when inside an NSTableCellView

╄→尐↘猪︶ㄣ 提交于 2019-11-29 10:49:56

Subclass NSTableCellView, with an outlet for the text field, and set the text field delegate in awakeFromNib. After doing that, control:textShouldBeginEditing: gets called. I'm not sure why, but (edit:) if you set the delegate in the xib, the delegate methods aren't called – I had the same experience as you.

Alternatively, you can forego the delegate and conditionally set Editable using a binding, either to a boolean property of the model, or using a value transformer which acts on a model instance and returns a boolean. Use the Editable binding of the text field.

tubtub

I've encountered this problem, too. Because I didn't want to lose the bindings, I did the following:

Binding editable of the TextField to the objectValue and set up a custom NSValueTransformer subclass.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!