NSResponder chain being broken after i remove / insert views

烂漫一生 提交于 2020-01-07 03:07:22

问题


It appears that when i remove subviews from my NSViewController main view, responder chain gets modified and new views never receive the first responder.

View controller is inside popover. There is search field on top, and custom views below (search results). When i show popover i can use tab to go to the custom views. But if i search for some phrase search results are changed and tab no longer works.

Any idea if there is way to 'fix' the responder chain ?


回答1:


Answer from Mike Abdullah

NSPopover: Key View Loop

While poking around NSPopover, one discovery has slightly surprised me: The NSWindow that AppKit creates behind the scenes for the popover has autorecalculatesKeyViewLoop turned off. That can have slightly odd consequences if you’re dynamically changing the content or layout of the popover, since AppKit won’t take those changes into account.

(If you need a quick explanation, The Key View Loop defines what happens when you hit the tab key, which control the focus moves to)

Since we don’t own the window in question, I’m a little hesitant to turn autorecalculatesKeyViewLoop on. Instead, it’s generally pretty simple to call recalculateKeyViewLoop on the window after you’ve made a change.



来源:https://stackoverflow.com/questions/34612744/nsresponder-chain-being-broken-after-i-remove-insert-views

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