一种使用 NSCollectionView 将事件转发到多个视图的方法
我正在尝试将键盘事件从集合视图转发到它包含的所有视图。我尝试找出如何获取视图数组,以便可以将事件转发到每个视图,但我找不到方法来执行此操作。我觉得我处理这件事的方式是错误的。任何方向都值得赞赏。
谢谢你,
查理
I am trying to forward a keyboard event from the Collection View to all the views it contains. I've tried figuring out how to obtain an array of the views so that I could forward the event to each view, but I could not find a way to do this. I feel that I am going about this the wrong way. Any direction is appreciated.
Thank you,
charlie
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为你是对的(你的处理方式是错误的)。为什么要短路(或重击)事件处理机制?
如何在接收事件的视图上响应事件,然后简单地向所有其他 NSCollectionViewItems 发送消息以根据需要进行响应?
或者让目标项目的视图发布一个所有集合视图项目都会监听的通知怎么样?您可以将目标视图作为通知对象传递,然后在处理通知时,如果通知对象== self,则忽略它。
I think you're right (you're going about this the wrong way). Why short-circuit (or bludgeon) the event handling mechanism?
How about responding to the event on the view that receives it, then simply messaging all the other NSCollectionViewItems to respond as desired?
Or how about having the targeted item's view post a notification for which all collection view items listen? You could pass the targeted view as the notification object, then when handling the notification, ignore it if the notification object == self.