Index: ui/base/cocoa/command_dispatcher.h |
diff --git a/ui/base/cocoa/command_dispatcher.h b/ui/base/cocoa/command_dispatcher.h |
index e6171390d12a37fb40e4444bbbfa34ce938167e6..2e565767c8a3a8af413ad3666611fa95a9479fb2 100644 |
--- a/ui/base/cocoa/command_dispatcher.h |
+++ b/ui/base/cocoa/command_dispatcher.h |
@@ -11,6 +11,7 @@ |
@protocol CommandDispatcherDelegate; |
@protocol CommandDispatchingWindow; |
+@protocol UserInterfaceItemCommandHandler; |
// CommandDispatcher guides the processing of key events to ensure key commands |
// are executed in the appropriate order. In particular, it allows a first |
@@ -78,7 +79,9 @@ |
// The set of methods an NSWindow subclass needs to implement to use |
// CommandDispatcher. |
-@protocol CommandDispatchingWindow |
+@protocol CommandDispatchingWindow<NSUserInterfaceValidations> |
tapted
2015/08/27 07:24:42
does the window need to implement this (i.e. is th
jackhou1
2015/09/03 01:12:49
Yeah it's not necessary to require this.
|
+ |
+@property(assign, nonatomic) id<UserInterfaceItemCommandHandler> commandHandler; |
tapted
2015/08/27 07:24:42
Could we just force the owner to implement this?
jackhou1
2015/09/03 01:12:49
Yeah, this is only used to set it on NativeWidgetM
|
// This can be implemented with -[CommandDispatcher redispatchKeyEvent:]. It's |
// so that callers can simply return events to the NSWindow. |
@@ -88,6 +91,39 @@ |
// CommandDispatcher calls as part of its -performKeyEquivalent flow. |
- (BOOL)defaultPerformKeyEquivalent:(NSEvent*)event; |
+// AppKit will call -[NSUserInterfaceValidations validateUserInterfaceItem:] to |
+// validate UI items. Any item whose target is FirstResponder, or nil, will |
+// traverse the responder chain looking for a responder that implements the |
+// item's selector. Thus NSWindow is usually the last to be checked and will |
+// handle any items that are not validated elsewhere in the chain. Implement the |
+// following so that menu items with these selectors are validated by |
+// CommandDispatchingWindow. |
+- (void)commandDispatch:(id)sender; |
tapted
2015/08/28 05:04:02
What's calling these?
What happens if we refactor
jackhou1
2015/09/03 01:12:49
These are hard coded in the nibs. I.e. a button mi
|
+- (void)commandDispatchUsingKeyModifiers:(id)sender; |
+ |
+@end |
+ |
+// Used by CommandDispatchingWindow to implement UI item validation. |
+@protocol UserInterfaceItemCommandHandler |
+ |
+// Called by CommandDispatchingWindow to validate menu and toolbar items. All |
+// the items we care about have been set with the -commandDispatch or |
+// -commandDispatchUsingKeyModifiers selectors and a target of FirstResponder in |
+// IB. If it's not one of those, it should be handled elsewhere in the responder |
+// chain. |
+- (BOOL)validateUserInterfaceItem:(id<NSValidatedUserInterfaceItem>)item |
+ window:(NSWindow*)window; |
+ |
+// Called by CommandDispatchingWindow to execute commands. This assumes that the |
+// command is supported and doesn't check, otherwise it would have been disabled |
+// in the UI in validateUserInterfaceItem:. |
+- (void)commandDispatch:(id)sender window:(NSWindow*)window; |
+ |
+// Same as |-commandDispatch:|, but executes commands using a disposition |
+// determined by the key flags. If the window is in the background and the |
+// command key is down, ignore the command key, but process any other modifiers. |
+- (void)commandDispatchUsingKeyModifiers:(id)sender window:(NSWindow*)window; |
+ |
@end |
#endif // UI_BASE_COCOA_COMMAND_DISPATCHER_H_ |