From c083e5c5fb7140cdbbeef1adb1e808611d46596e Mon Sep 17 00:00:00 2001
From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
Date: Sun, 15 Dec 2024 15:59:36 +0100
Subject: [PATCH] Fix: Crash on macOS if Escape is pressed while Help submenu
 is open (#1170)

---
 src/Fl_cocoa.mm | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm
index 6e16ac02a..b916b3b46 100644
--- a/src/Fl_cocoa.mm
+++ b/src/Fl_cocoa.mm
@@ -2630,6 +2630,8 @@ static FLTextInputContext* fltextinputcontext_instance = nil;
 }
 - (void)keyUp:(NSEvent *)theEvent {
   //NSLog(@"keyUp:%@",[theEvent characters]);
+  if (![[theEvent window] isKindOfClass:[FLWindow class]]) // issue #1170
+    return [super keyUp:theEvent];
   fl_lock_function();
   Fl_Window *window = (Fl_Window*)[(FLWindow*)[theEvent window] getFl_Window];
   Fl::first_window(window);
-- 
GitLab