问题
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