1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef UI_BASE_COCOA_USER_INTERFACE_ITEM_COMMAND_HANDLER_H_
6 #define UI_BASE_COCOA_USER_INTERFACE_ITEM_COMMAND_HANDLER_H_
8 #import <Cocoa/Cocoa.h>
10 // Used by CommandDispatchingWindow to implement NSUserInterfaceItemValidations
11 // for items with -commandDispatch: and -commandDispatchUsingKeyModifiers:.
12 @protocol UserInterfaceItemCommandHandler
<NSObject
>
14 // Called by CommandDispatchingWindow to validate menu and toolbar items. All
15 // the items we care about have been set with the -commandDispatch or
16 // -commandDispatchUsingKeyModifiers selectors and a target of FirstResponder in
17 // IB. If it's not one of those, it should be handled elsewhere in the responder
19 - (BOOL
)validateUserInterfaceItem
:(id
<NSValidatedUserInterfaceItem
>)item
20 window
:(NSWindow
*)window
;
22 // Called by CommandDispatchingWindow to execute commands. This assumes that the
23 // command is supported and doesn't check, otherwise it would have been disabled
24 // in the UI in validateUserInterfaceItem:.
25 - (void)commandDispatch
:(id
)sender window
:(NSWindow
*)window
;
27 // Same as |-commandDispatch:|, but executes commands using a disposition
28 // determined by the key flags. If the window is in the background and the
29 // command key is down, ignore the command key, but process any other modifiers.
30 - (void)commandDispatchUsingKeyModifiers
:(id
)sender window
:(NSWindow
*)window
;
34 #endif // UI_BASE_COCOA_USER_INTERFACE_ITEM_COMMAND_HANDLER_H_