Obj-C: Why is my NSTextField subclass having an effect on objects I haven't assigned to it?

后端 未结 1 1161
借酒劲吻你
借酒劲吻你 2021-01-16 04:53

I have an NSPanel with about 4 different NSTextField\'s on it. I\'m looking at getting the usual cut, copy, paste, selectAll working for some of the fields.

The best

相关标签:
1条回答
  • 2021-01-16 05:08

    From the article you linked to:

    One interesting thing about this solution is that the handler object does not need to be the target view for actions. You could make a single NSButton perform the copy and paste operations for your whole window, if you'd like. (This is similar to the way that a single menu item can perform copy or paste operations for your whole application.)

    The search for a view which wants to handle a key equivalent does not care which view is first responder. It searches the entire view hierarchy. Once it finds the single AXCVHandler, that object performs the key equivalent. The way it performs it is to send a corresponding action to the responder chain, which does begin at the first responder. So, that one AXCVHandler object is sufficient to direct the appropriate action to any of your text fields because any of them can be the first responder.

    0 讨论(0)
提交回复
热议问题