From 0729b0806ea6f0ad8e3c7b173617c7b4c475745a Mon Sep 17 00:00:00 2001 From: James Turner Date: Thu, 31 Jan 2013 18:42:34 +0000 Subject: [PATCH] Fix numeric keypad support on Mac. Comments in the code imply osgViewer always sends 'num-lock'-off codes, but that is not the observed behaviour with Cocoa. So adding mappings for the num-locked codes on Mac, which is what people actually want at the moment. --- src/Viewer/FGEventHandler.cxx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Viewer/FGEventHandler.cxx b/src/Viewer/FGEventHandler.cxx index b0f9bcd1d..b877cc746 100644 --- a/src/Viewer/FGEventHandler.cxx +++ b/src/Viewer/FGEventHandler.cxx @@ -68,6 +68,21 @@ FGEventHandler::FGEventHandler() : numlockKeyMap[GUIEventAdapter::KEY_KP_Page_Up] = '9'; numlockKeyMap[GUIEventAdapter::KEY_KP_Delete] = '.'; + // The comment above is incorrect on Mac osgViewer, at least. So we + // need to map the 'num-locked' key codes to real values. + numlockKeyMap[GUIEventAdapter::KEY_KP_0] = '0'; + numlockKeyMap[GUIEventAdapter::KEY_KP_1] = '1'; + numlockKeyMap[GUIEventAdapter::KEY_KP_2] = '2'; + numlockKeyMap[GUIEventAdapter::KEY_KP_3] = '3'; + numlockKeyMap[GUIEventAdapter::KEY_KP_4] = '4'; + numlockKeyMap[GUIEventAdapter::KEY_KP_5] = '5'; + numlockKeyMap[GUIEventAdapter::KEY_KP_6] = '6'; + numlockKeyMap[GUIEventAdapter::KEY_KP_7] = '7'; + numlockKeyMap[GUIEventAdapter::KEY_KP_8] = '8'; + numlockKeyMap[GUIEventAdapter::KEY_KP_9] = '9'; + numlockKeyMap[GUIEventAdapter::KEY_KP_Decimal] = '.'; + + // mapping when NumLock is off noNumlockKeyMap[GUIEventAdapter::KEY_KP_Insert] = PU_KEY_INSERT; noNumlockKeyMap[GUIEventAdapter::KEY_KP_End] = PU_KEY_END; -- 2.39.5