Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Side by Side Diff: ui/base/cocoa/command_dispatcher.h

Issue 1250403002: [Mac] Move UI item validation to UserInterfaceItemCommandHandler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@commandexecute
Patch Set: Properly release |commandHandler|. Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/base/BUILD.gn ('k') | ui/base/cocoa/user_interface_item_command_handler.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef UI_BASE_COCOA_COMMAND_DISPATCHER_H_ 5 #ifndef UI_BASE_COCOA_COMMAND_DISPATCHER_H_
6 #define UI_BASE_COCOA_COMMAND_DISPATCHER_H_ 6 #define UI_BASE_COCOA_COMMAND_DISPATCHER_H_
7 7
8 #import <Cocoa/Cocoa.h> 8 #import <Cocoa/Cocoa.h>
9 9
10 #import "base/mac/scoped_nsobject.h" 10 #import "base/mac/scoped_nsobject.h"
11 #include "ui/base/ui_base_export.h" 11 #include "ui/base/ui_base_export.h"
12 12
13 @protocol CommandDispatcherDelegate; 13 @protocol CommandDispatcherDelegate;
14 @protocol CommandDispatchingWindow; 14 @protocol CommandDispatchingWindow;
15 @protocol UserInterfaceItemCommandHandler;
15 16
16 // CommandDispatcher guides the processing of key events to ensure key commands 17 // CommandDispatcher guides the processing of key events to ensure key commands
17 // are executed in the appropriate order. In particular, it allows a first 18 // are executed in the appropriate order. In particular, it allows a first
18 // responder implementing CommandDispatcherTarget to handle an event 19 // responder implementing CommandDispatcherTarget to handle an event
19 // asynchronously and return unhandled events via -redispatchKeyEvent:. An 20 // asynchronously and return unhandled events via -redispatchKeyEvent:. An
20 // NSWindow can use CommandDispatcher by implementing CommandDispatchingWindow 21 // NSWindow can use CommandDispatcher by implementing CommandDispatchingWindow
21 // and overriding -[NSWindow performKeyEquivalent:] and -[NSWindow sendEvent:] 22 // and overriding -[NSWindow performKeyEquivalent:] and -[NSWindow sendEvent:]
22 // to call the respective CommandDispatcher methods. 23 // to call the respective CommandDispatcher methods.
23 UI_BASE_EXPORT @interface CommandDispatcher : NSObject 24 UI_BASE_EXPORT @interface CommandDispatcher : NSObject
24 25
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 // Called after the default -performKeyEquivalent:. |window| is the 75 // Called after the default -performKeyEquivalent:. |window| is the
75 // CommandDispatchingWindow that owns CommandDispatcher. 76 // CommandDispatchingWindow that owns CommandDispatcher.
76 - (BOOL)postPerformKeyEquivalent:(NSEvent*)event window:(NSWindow*)window; 77 - (BOOL)postPerformKeyEquivalent:(NSEvent*)event window:(NSWindow*)window;
77 78
78 @end 79 @end
79 80
80 // The set of methods an NSWindow subclass needs to implement to use 81 // The set of methods an NSWindow subclass needs to implement to use
81 // CommandDispatcher. 82 // CommandDispatcher.
82 @protocol CommandDispatchingWindow 83 @protocol CommandDispatchingWindow
83 84
85 // If set, NSUserInterfaceItemValidations for -commandDispatch: and
86 // -commandDispatchUsingKeyModifiers: will be redirected to the command handler.
87 // Retains |commandHandler|.
88 -(void)setCommandHandler:(id<UserInterfaceItemCommandHandler>) commandHandler;
89
84 // This can be implemented with -[CommandDispatcher redispatchKeyEvent:]. It's 90 // This can be implemented with -[CommandDispatcher redispatchKeyEvent:]. It's
85 // so that callers can simply return events to the NSWindow. 91 // so that callers can simply return events to the NSWindow.
86 - (BOOL)redispatchKeyEvent:(NSEvent*)event; 92 - (BOOL)redispatchKeyEvent:(NSEvent*)event;
87 93
88 // Short-circuit to the default -[NSResponder performKeyEquivalent:] which 94 // Short-circuit to the default -[NSResponder performKeyEquivalent:] which
89 // CommandDispatcher calls as part of its -performKeyEquivalent: flow. 95 // CommandDispatcher calls as part of its -performKeyEquivalent: flow.
90 - (BOOL)defaultPerformKeyEquivalent:(NSEvent*)event; 96 - (BOOL)defaultPerformKeyEquivalent:(NSEvent*)event;
91 97
98 // AppKit will call -[NSUserInterfaceValidations validateUserInterfaceItem:] to
99 // validate UI items. Any item whose target is FirstResponder, or nil, will
100 // traverse the responder chain looking for a responder that implements the
101 // item's selector. Thus NSWindow is usually the last to be checked and will
102 // handle any items that are not validated elsewhere in the chain. Implement the
103 // following so that menu items with these selectors are validated by
104 // CommandDispatchingWindow.
105 - (void)commandDispatch:(id)sender;
106 - (void)commandDispatchUsingKeyModifiers:(id)sender;
107
92 @end 108 @end
93 109
94 #endif // UI_BASE_COCOA_COMMAND_DISPATCHER_H_ 110 #endif // UI_BASE_COCOA_COMMAND_DISPATCHER_H_
OLDNEW
« no previous file with comments | « ui/base/BUILD.gn ('k') | ui/base/cocoa/user_interface_item_command_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698