From 45aacd840752bc1af07677da44af4911dbd701c8 Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Thu, 29 Apr 2021 12:52:41 +0200 Subject: [PATCH] Use `initialFirstResponder` instead of `makeFirstResponder` (#1920) As recommended by the documentation: https://developer.apple.com/documentation/appkit/nswindow/1419366-makefirstresponder?language=objc --- src/platform_impl/macos/window.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/platform_impl/macos/window.rs b/src/platform_impl/macos/window.rs index 11c652c5..7d16f2fc 100644 --- a/src/platform_impl/macos/window.rs +++ b/src/platform_impl/macos/window.rs @@ -131,8 +131,6 @@ unsafe fn create_view( ns_view.setWantsLayer(YES); } - ns_window.setContentView_(*ns_view); - ns_window.makeFirstResponder_(*ns_view); (ns_view, cursor_state) }) } @@ -377,6 +375,12 @@ impl UnownedWindow { os_error!(OsError::CreationError("Couldn't create `NSView`")) })?; + // Configure the new view as the "key view" for the window + unsafe { + ns_window.setContentView_(*ns_view); + ns_window.setInitialFirstResponder_(*ns_view); + } + let input_context = unsafe { util::create_input_context(*ns_view) }; let scale_factor = unsafe { NSWindow::backingScaleFactor(*ns_window) as f64 };