summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorManolo Gouy <Manolo>2015-12-13 09:51:07 +0000
committerManolo Gouy <Manolo>2015-12-13 09:51:07 +0000
commit09cd712c0d0e337bc7505cb8ae00d1a3fdbe8ee5 (patch)
treefa0eca283e164bb616e2a6d97924d2e6b5d5e2bb /src
parentcf14f77a901a64f12c5a103b782954692d8f6643 (diff)
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
Diffstat (limited to 'src')
-rw-r--r--src/Fl_cocoa.mm4
1 files changed, 3 insertions, 1 deletions
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<mods ) ? FL_KEYBOARD : FL_KEYUP;