From 8269c91886a19e3f5c804d508cb75ddbaa70a7b5 Mon Sep 17 00:00:00 2001 From: Alex Wood Date: Thu, 23 Jun 2022 13:21:04 -0700 Subject: [PATCH] [MacOS] Accept first mouse-down (flutter/engine#34093) --- .../platform/darwin/macos/framework/Source/FlutterView.mm | 8 ++++++++ .../macos/framework/Source/FlutterViewControllerTest.mm | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/engine/src/flutter/shell/platform/darwin/macos/framework/Source/FlutterView.mm b/engine/src/flutter/shell/platform/darwin/macos/framework/Source/FlutterView.mm index 6d5377350d..063e2aab81 100644 --- a/engine/src/flutter/shell/platform/darwin/macos/framework/Source/FlutterView.mm +++ b/engine/src/flutter/shell/platform/darwin/macos/framework/Source/FlutterView.mm @@ -98,6 +98,14 @@ return YES; } +/** + * Declares that the initial mouse-down when the view is not in focus will send an event to the + * view. + */ +- (BOOL)acceptsFirstMouse:(NSEvent*)event { + return YES; +} + - (BOOL)acceptsFirstResponder { return YES; } diff --git a/engine/src/flutter/shell/platform/darwin/macos/framework/Source/FlutterViewControllerTest.mm b/engine/src/flutter/shell/platform/darwin/macos/framework/Source/FlutterViewControllerTest.mm index 7d29c1811b..1d78483985 100644 --- a/engine/src/flutter/shell/platform/darwin/macos/framework/Source/FlutterViewControllerTest.mm +++ b/engine/src/flutter/shell/platform/darwin/macos/framework/Source/FlutterViewControllerTest.mm @@ -72,6 +72,12 @@ TEST(FlutterViewController, HasViewThatHidesOtherViewsInAccessibility) { EXPECT_EQ(accessibilityChildren[0], viewControllerMock.flutterView); } +TEST(FlutterViewController, FlutterViewAcceptsFirstMouse) { + FlutterViewController* viewControllerMock = CreateMockViewController(); + [viewControllerMock loadView]; + EXPECT_EQ([viewControllerMock.flutterView acceptsFirstMouse:nil], YES); +} + TEST(FlutterViewController, ReparentsPluginWhenAccessibilityDisabled) { FlutterEngine* engine = CreateTestEngine(); NSString* fixtures = @(testing::GetFixturesPath());