我删除/插入视图后,NSResponder链断裂

编程入门 行业动态 更新时间:2024-10-24 18:29:08
本文介绍了我删除/插入视图后,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链断裂

本文发布于:2023-11-30 04:05:19,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1648656.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:视图   链断裂   NSResponder

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!