简体   繁体   English

如何在响应者链中保持隐藏视图?

[英]How to keep a hidden view in responder chain?

I have a NSSplitViewController and in one of the items I have multiple buttons with keyboard shortcuts. 我有一个NSSplitViewController ,在其中一项中,我有多个带有键盘快捷键的按钮。

Once the user hides the item, the shortcuts don't fire. 一旦用户隐藏了项目,快捷方式就不会触发。 Is there any way to keep the buttons in the hidden view as part of the responder chain? 有什么方法可以将按钮保留在隐藏视图中,作为响应者链的一部分?

Sounds like the simple answer is no, according to Apple's docs . 根据Apple的文档 ,听起来简单的答案是否定 A simple workaround, however, might be to move the buttons out of the visible area by, say, shifting their bounds right by 10,000 or so. 但是,一种简单的解决方法可能是通过将按钮的边界向右移动10,000左右来将按钮移出可见区域。 If they are in a scrollview/clipview that would expand to show the items in their new position, then this would not work so well, but if they aren't, it ought to work fine. 如果它们处于可扩展以将项目显示在其新位置的scrollview / clipview中,则该方法将不能很好地工作,但是如果不是,则应该可以正常工作。 If they are in a scrollview, then you might find a way to make them completely transparent, to achieve a similar effect. 如果它们在滚动视图中,那么您可能会找到一种使它们完全透明的方法,以实现类似的效果。

That said, perhaps it is worth considering whether you have the right design in the first place, since having buttons that are not visible respond to key events is a questionable design from a user-interface perspective (as reflected by the fact that Apple tries to prevent it). 就是说,也许值得一开始就考虑一下您是否具有正确的设计,因为从用户界面的角度来看,让不可见的按钮响应按键事件是一个有问题的设计(这一点反映在Apple试图防止它)。 Maybe those keyboard events should really be getting handled by a view higher in the view hierarchy, or by the window, or some such entity? 也许这些键盘事件确实应该由视图层次结构中较高的视图,窗口或某些此类实体处理?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM