删除/插入视图后 NSResponder 链被破坏
NSResponder chain being broken after i remove / insert views
似乎当我从我的 NSViewController 主视图中删除子视图时,响应者链被修改并且新视图从未接收到第一响应者。
视图控制器在弹出框内。顶部是搜索字段,下方是自定义视图(搜索结果)。当我显示弹出窗口时,我可以使用选项卡转到自定义视图。但是如果我搜索一些词组,搜索结果就会改变,标签就不再有效了。
知道是否有办法 'fix' 响应者链吗?
迈克·阿卜杜拉的回答
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.
似乎当我从我的 NSViewController 主视图中删除子视图时,响应者链被修改并且新视图从未接收到第一响应者。
视图控制器在弹出框内。顶部是搜索字段,下方是自定义视图(搜索结果)。当我显示弹出窗口时,我可以使用选项卡转到自定义视图。但是如果我搜索一些词组,搜索结果就会改变,标签就不再有效了。
知道是否有办法 'fix' 响应者链吗?
迈克·阿卜杜拉的回答
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.