我删除/插入视图后,NSResponder链断裂 [英] NSResponder chain being broken after i remove / insert views

查看:88
本文介绍了我删除/插入视图后,NSResponder链断裂的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

看来,当我从我的NSViewController主视图中删除子视图时,响应者链被修改,新视图永远不会收到第一个响应者.

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 ?

推荐答案

迈克·阿卜杜拉的答案

NSPopover:键视图循环

在NSPopover上进行浏览时,一个发现使我有些惊讶:AppKit在幕后为弹出窗口创建的NSWindow已自动重新计算KeyViewLoop.如果您动态更改弹出框的内容或布局,那可能会产生一些奇怪的后果,因为AppKit不会考虑这些更改.

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.

(如果需要快速说明,键视图循环"将定义当您按下Tab键时会发生的情况,该键控制焦点移至该键)

(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)

由于我们不拥有该窗口,因此我有点犹豫是否要打开autorecalculatesKeyViewLoop.取而代之的是,通常在进行更改后在窗口上调用recalculateKeyViewLoop很简单.

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.

这篇关于我删除/插入视图后,NSResponder链断裂的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆