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

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: Sync 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
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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 @protocol CommandDispatchingWindow 83 @protocol CommandDispatchingWindow
83 84
84 // This can be implemented with -[CommandDispatcher redispatchKeyEvent:]. It's 85 // This can be implemented with -[CommandDispatcher redispatchKeyEvent:]. It's
85 // so that callers can simply return events to the NSWindow. 86 // so that callers can simply return events to the NSWindow.
86 - (BOOL)redispatchKeyEvent:(NSEvent*)event; 87 - (BOOL)redispatchKeyEvent:(NSEvent*)event;
87 88
88 // Short-circuit to the default -[NSResponder performKeyEquivalent:] which 89 // Short-circuit to the default -[NSResponder performKeyEquivalent:] which
89 // CommandDispatcher calls as part of its -performKeyEquivalent: flow. 90 // CommandDispatcher calls as part of its -performKeyEquivalent: flow.
90 - (BOOL)defaultPerformKeyEquivalent:(NSEvent*)event; 91 - (BOOL)defaultPerformKeyEquivalent:(NSEvent*)event;
91 92
93 // AppKit will call -[NSUserInterfaceValidations validateUserInterfaceItem:] to
94 // validate UI items. Any item whose target is FirstResponder, or nil, will
95 // traverse the responder chain looking for a responder that implements the
96 // item's selector. Thus NSWindow is usually the last to be checked and will
97 // handle any items that are not validated elsewhere in the chain. Implement the
98 // following so that menu items with these selectors are validated by
99 // CommandDispatchingWindow.
100 - (void)commandDispatch:(id)sender;
101 - (void)commandDispatchUsingKeyModifiers:(id)sender;
102
103 @end
104
105 // Used by CommandDispatchingWindow to implement UI item validation.
106 @protocol UserInterfaceItemCommandHandler
107
108 // Called by CommandDispatchingWindow to validate menu and toolbar items. All
109 // the items we care about have been set with the -commandDispatch or
110 // -commandDispatchUsingKeyModifiers selectors and a target of FirstResponder in
111 // IB. If it's not one of those, it should be handled elsewhere in the responder
112 // chain.
113 - (BOOL)validateUserInterfaceItem:(id<NSValidatedUserInterfaceItem>)item
114 window:(NSWindow*)window;
115
116 // Called by CommandDispatchingWindow to execute commands. This assumes that the
117 // command is supported and doesn't check, otherwise it would have been disabled
118 // in the UI in validateUserInterfaceItem:.
119 - (void)commandDispatch:(id)sender window:(NSWindow*)window;
120
121 // Same as |-commandDispatch:|, but executes commands using a disposition
122 // determined by the key flags. If the window is in the background and the
123 // command key is down, ignore the command key, but process any other modifiers.
124 - (void)commandDispatchUsingKeyModifiers:(id)sender window:(NSWindow*)window;
125
92 @end 126 @end
93 127
94 #endif // UI_BASE_COCOA_COMMAND_DISPATCHER_H_ 128 #endif // UI_BASE_COCOA_COMMAND_DISPATCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698