Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 45886b7

Browse files
committed
Review Changes
1 parent 3e42251 commit 45886b7

File tree

4 files changed

+29
-30
lines changed

4 files changed

+29
-30
lines changed

shell/platform/darwin/macos/framework/Headers/FlutterViewController.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,6 @@ FLUTTER_EXPORT
3939
*/
4040
@property(nonatomic) FlutterMouseTrackingMode mouseTrackingMode;
4141

42-
/**
43-
* Initializes this FlutterViewController with the specified `FlutterEngine`.
44-
*
45-
* The initialized viewcontroller will attach itself to the engine as part of this process.
46-
*
47-
* @param engine The `FlutterEngine` instance to attach to. Cannot be nil.
48-
* @param nibName The NIB name to initialize this controller with.
49-
* @param nibBundle The NIB bundle.
50-
*/
51-
- (nonnull instancetype)initWithEngine:(nonnull FlutterEngine*)engine
52-
nibName:(nullable NSString*)nibName
53-
bundle:(nullable NSBundle*)nibBundle NS_DESIGNATED_INITIALIZER;
54-
5542
/**
5643
* Initializes a controller that will run the given project.
5744
*

shell/platform/darwin/macos/framework/Source/FlutterIntermediateKeyResponder.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,12 @@
55
#import <Cocoa/Cocoa.h>
66

77
/*
8-
* An interface for adding key responders that are processed after the framework
9-
* has had a chance to handle the key, but before the next responder is given
10-
* the key.
8+
* An interface for adding key responders that can declare itself as the final
9+
* responder of the event, terminating the event propagation.
1110
*
12-
* It differs from an NSResponder in that it returns a boolean from the keyUp
13-
* and keyDown calls, allowing the callee to indicate whether or not it handled
14-
* the given event. If handled, then the event is not passed to the next
15-
* responder.
11+
* It differs from an NSResponder in that it returns a boolean from the
12+
* handleKeyUp and handleKeyDown calls, where true means it has handled the
13+
* given event. A handled event is not passed to the next responder.
1614
*/
1715
@interface FlutterIntermediateKeyResponder : NSObject
1816
/*

shell/platform/darwin/macos/framework/Source/FlutterViewController.mm

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,12 @@ void Reset() {
8282
@interface FlutterViewController () <FlutterViewReshapeListener>
8383

8484
/**
85-
* A list of additional responders to keyboard events. Keybord events are forwarded to all of them.
85+
* A list of additional responders to keyboard events.
86+
*
87+
* Keyboard events received by FlutterViewController are first dispatched to
88+
* each additional responder in order. If any of them handle the event (by
89+
* returning true), the event is not dispatched to later additional responders
90+
* or to the nextResponder.
8691
*/
8792
@property(nonatomic) NSMutableOrderedSet<FlutterIntermediateKeyResponder*>* additionalKeyResponders;
8893

@@ -135,7 +140,8 @@ - (void)dispatchMouseEvent:(nonnull NSEvent*)event;
135140
- (void)dispatchMouseEvent:(nonnull NSEvent*)event phase:(FlutterPointerPhase)phase;
136141

137142
/**
138-
* Sends |event| to all responders in additionalKeyResponders and then to the nextResponder.
143+
* Sends |event| to all responders in additionalKeyResponders and then to the
144+
* nextResponder if none of the additional responders handled the event.
139145
*/
140146
- (void)propagateKeyEvent:(NSEvent*)event ofType:(NSString*)type;
141147

@@ -494,21 +500,17 @@ - (void)dispatchMouseEvent:(NSEvent*)event phase:(FlutterPointerPhase)phase {
494500
- (void)propagateKeyEvent:(NSEvent*)event ofType:(NSString*)type {
495501
if ([type isEqual:@"keydown"]) {
496502
for (FlutterIntermediateKeyResponder* responder in self.additionalKeyResponders) {
497-
if ([responder respondsToSelector:@selector(handleKeyDown:)]) {
498-
if ([responder handleKeyDown:event]) {
499-
return;
500-
}
503+
if ([responder handleKeyDown:event]) {
504+
return;
501505
}
502506
}
503507
if ([self.nextResponder respondsToSelector:@selector(keyDown:)]) {
504508
[self.nextResponder keyDown:event];
505509
}
506510
} else if ([type isEqual:@"keyup"]) {
507511
for (FlutterIntermediateKeyResponder* responder in self.additionalKeyResponders) {
508-
if ([responder respondsToSelector:@selector(handleKeyUp:)]) {
509-
if ([responder handleKeyUp:event]) {
510-
return;
511-
}
512+
if ([responder handleKeyUp:event]) {
513+
return;
512514
}
513515
}
514516
if ([self.nextResponder respondsToSelector:@selector(keyUp:)]) {

shell/platform/darwin/macos/framework/Source/FlutterViewController_Internal.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,16 @@
2828
*/
2929
- (void)removeKeyResponder:(nonnull FlutterIntermediateKeyResponder*)responder;
3030

31+
/**
32+
* Initializes this FlutterViewController with the specified `FlutterEngine`.
33+
*
34+
* The initialized viewcontroller will attach itself to the engine as part of this process.
35+
*
36+
* @param engine The `FlutterEngine` instance to attach to. Cannot be nil.
37+
* @param nibName The NIB name to initialize this controller with.
38+
* @param nibBundle The NIB bundle.
39+
*/
40+
- (nonnull instancetype)initWithEngine:(nonnull FlutterEngine*)engine
41+
nibName:(nullable NSString*)nibName
42+
bundle:(nullable NSBundle*)nibBundle NS_DESIGNATED_INITIALIZER;
3143
@end

0 commit comments

Comments
 (0)