From 09cd712c0d0e337bc7505cb8ae00d1a3fdbe8ee5 Mon Sep 17 00:00:00 2001 From: Manolo Gouy Date: Sun, 13 Dec 2015 09:51:07 +0000 Subject: Allowing to use FLTK objects in static initializers (cont'd). On the Mac platform, it is also necessary to change the initialization of the macKeyLookUp array for keyboard events to work in a static initializer. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10962 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/Fl_cocoa.mm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm index 5f0c32f0e..73a9a5f6f 100644 --- a/src/Fl_cocoa.mm +++ b/src/Fl_cocoa.mm @@ -158,7 +158,7 @@ void fl_set_status(int x, int y, int w, int h) /* * Mac keyboard lookup table */ -static unsigned short* macKeyLookUp = fl_compute_macKeyLookUp(); +static unsigned short* macKeyLookUp = NULL; /* * convert the current mouse chord into the FLTK modifier state @@ -2177,6 +2177,7 @@ static void cocoaKeyboardHandler(NSEvent *theEvent) // printf("%08x %08x %08x\n", keyCode, mods, key); maskedKeyCode = keyCode & 0x7f; mods_to_e_state( mods ); // process modifier keys + if (!macKeyLookUp) macKeyLookUp = fl_compute_macKeyLookUp(); sym = macKeyLookUp[maskedKeyCode]; if (sym < 0xff00) { // a "simple" key // find the result of this key without modifier @@ -2417,6 +2418,7 @@ static FLTextInputContext* fltextinputcontext_instance = nil; if ( tMods ) { unsigned short keycode = [theEvent keyCode]; + if (!macKeyLookUp) macKeyLookUp = fl_compute_macKeyLookUp(); Fl::e_keysym = Fl::e_original_keysym = macKeyLookUp[keycode & 0x7f]; if ( Fl::e_keysym ) sendEvent = ( prevMods