diff --git a/Sources/UntoldEngine/Systems/InputSystem+Keyboard.swift b/Sources/UntoldEngine/Systems/InputSystem+Keyboard.swift index 0edc8180e..0ded7b159 100644 --- a/Sources/UntoldEngine/Systems/InputSystem+Keyboard.swift +++ b/Sources/UntoldEngine/Systems/InputSystem+Keyboard.swift @@ -140,7 +140,17 @@ public extension InputSystem { // real keyboard focus (click, cursor appears) without reliably posting it, so // this falls back to asking the key window directly what's actually focused // right now, rather than trusting a notification that may never have fired. - if let responder = NSApp.keyWindow?.firstResponder, responder is NSText { + // This method is only ever called from an NSEvent local monitor handler, which + // AppKit always invokes on the main thread, so the isolation is actually held — + // assumeIsolated just proves that to the compiler instead of marking this whole + // (nonisolated-callable) type @MainActor. + let hasTextResponder = MainActor.assumeIsolated { + if let responder = NSApp.keyWindow?.firstResponder, responder is NSText { + return true + } + return false + } + if hasTextResponder { return false } return true