diff options
| author | Matthias Melcher <fltk@matthiasm.com> | 2006-06-09 07:48:08 +0000 |
|---|---|---|
| committer | Matthias Melcher <fltk@matthiasm.com> | 2006-06-09 07:48:08 +0000 |
| commit | 428a283f83e3c9c6e683062079cacbebf43ce3ab (patch) | |
| tree | db03643ede1581ef312615c624005b2c69b15b2d | |
| parent | 007fc30ca4e26595c3a21dd07600e6517d5914a4 (diff) | |
Added an event variable "Fl::event_original_key()" which returns the current key code (see Fl::event_key()) before it gets mangled through the NumLock keypad conversion. This way, an application can differentiate between an arrow key and a numeric keypad w/NumLock off.
On Win32, releasing a numeric keypad key w/NumLock off wiould return the wrong keycode (keypad instead of arrow key).
Documentation changed accordingly. X11 code is yet to be tested.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@5188 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
| -rw-r--r-- | CHANGES | 2 | ||||
| -rw-r--r-- | FL/Fl.H | 3 | ||||
| -rw-r--r-- | documentation/Fl.html | 9 | ||||
| -rw-r--r-- | src/Fl.cxx | 3 | ||||
| -rw-r--r-- | src/Fl_mac.cxx | 2 | ||||
| -rw-r--r-- | src/Fl_win32.cxx | 10 | ||||
| -rw-r--r-- | src/Fl_x.cxx | 2 |
7 files changed, 24 insertions, 7 deletions
@@ -1,5 +1,7 @@ CHANGES IN FLTK 1.1.8 + - New function Fl::event_original_key() returns key + code before NumLock handling. - Many OS X Quartz fixes (STR #1310, etc.) - Fixed shortcut and default focus for message dialogs (STR #1298) @@ -82,6 +82,8 @@ public: // should be private! static const char* scheme_; static Fl_Image* scheme_bg_; + static int e_original_keysym; // late addition + public: // API version number @@ -159,6 +161,7 @@ public: static int event_state() {return e_state;} static int event_state(int i) {return e_state&i;} static int event_key() {return e_keysym;} + static int event_original_key(){return e_original_keysym;} static int event_key(int); static int get_key(int); static const char* event_text() {return e_text;} diff --git a/documentation/Fl.html b/documentation/Fl.html index a66e3fe39..ac42de887 100644 --- a/documentation/Fl.html +++ b/documentation/Fl.html @@ -69,6 +69,7 @@ state information and global methods for the current application.</P> <LI><A HREF="#Fl.event_is_click">event_is_click</A></LI> <LI><A HREF="#Fl.event_key">event_key</A></LI> <LI><A HREF="#Fl.event_length">event_length</A></LI> + <LI><A HREF="#Fl.event_original_key">event_original_key</A></LI> <LI><A HREF="#Fl.event_shift">event_shift</A></LI> <LI><A HREF="#Fl.event_state">event_state</A></LI> <LI><A HREF="#Fl.event_text">event_text</A></LI> @@ -660,6 +661,14 @@ will always be a nul at this position in the text. However there may be a nul before that if the keystroke translates to a nul character or you paste a nul character. +<H4><A NAME="Fl.event_original_key">int event_original_key();</A></H4> + +<P> If NumLock is deactivated, FLTK translates events from the +numeric keypad into the corresponding arrow key events. +<tt>event_key()</tt> returns the translated key code, whereas +<tt>event_original_key()</tt> returns the keycode before +NumLock translation. + <H4><A NAME="Fl.event_shift">int event_shift();</A></H4> <P>Returns non-zero if the Shift key is pressed. diff --git a/src/Fl.cxx b/src/Fl.cxx index 2064ce3ac..18ceb5d6d 100644 --- a/src/Fl.cxx +++ b/src/Fl.cxx @@ -71,7 +71,8 @@ int Fl::damage_, Fl::e_state, Fl::e_clicks, Fl::e_is_click, - Fl::e_keysym; + Fl::e_keysym, + Fl::e_original_keysym; char *Fl::e_text = (char *)""; int Fl::e_length; int Fl::visible_focus_ = 1, diff --git a/src/Fl_mac.cxx b/src/Fl_mac.cxx index d2849e419..0a667a461 100644 --- a/src/Fl_mac.cxx +++ b/src/Fl_mac.cxx @@ -1108,7 +1108,7 @@ pascal OSStatus carbonKeyboardHandler( sym = keycode_to_sym( keyCode & 0x7f, 0, macKeyLookUp[ keyCode & 0x7f ] ); else sym = macKeyLookUp[ keyCode & 0x7f ]; - Fl::e_keysym = sym; + Fl::e_keysym = Fl::e_original_keysym = sym; // Handle FL_KP_Enter on regular keyboards and on Powerbooks if ( keyCode==0x4c || keyCode==0x34) key=0x0d; // Matt: the Mac has no concept of a NumLock key, or at least not visible diff --git a/src/Fl_win32.cxx b/src/Fl_win32.cxx index ade91e1c9..401c1b7a9 100644 --- a/src/Fl_win32.cxx +++ b/src/Fl_win32.cxx @@ -803,7 +803,7 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar case WM_KEYUP: case WM_SYSKEYUP: // save the keysym until we figure out the characters: - Fl::e_keysym = ms2fltk(wParam,lParam&(1<<24)); + Fl::e_keysym = Fl::e_original_keysym = ms2fltk(wParam,lParam&(1<<24)); // See if TranslateMessage turned it into a WM_*CHAR message: if (PeekMessage(&fl_msg, hWnd, WM_CHAR, WM_SYSDEADCHAR, PM_REMOVE)) { uMsg = fl_msg.message; @@ -832,10 +832,6 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar } if (GetKeyState(VK_SCROLL)) state |= FL_SCROLL_LOCK; Fl::e_state = state; - if (lParam & (1<<31)) { // key up events. - if (Fl::handle(FL_KEYUP, window)) return 0; - break; - } static char buffer[2]; if (uMsg == WM_CHAR || uMsg == WM_SYSCHAR) { buffer[0] = char(wParam); @@ -894,6 +890,10 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar Fl::e_length = 0; } Fl::e_text = buffer; + if (lParam & (1<<31)) { // key up events. + if (Fl::handle(FL_KEYUP, window)) return 0; + break; + } // for (int i = lParam&0xff; i--;) while (window->parent()) window = window->window(); if (Fl::handle(FL_KEYBOARD,window)) return 0; diff --git a/src/Fl_x.cxx b/src/Fl_x.cxx index cde677408..0e4dd4a56 100644 --- a/src/Fl_x.cxx +++ b/src/Fl_x.cxx @@ -834,6 +834,8 @@ int fl_handle(const XEvent& thisevent) else if (keysym == FL_BackSpace) got_backspace = 1; } # endif + // Store this so we can later know if the KP was used + Fl::e_original_keysym = keysym; // We have to get rid of the XK_KP_function keys, because they are // not produced on Windoze and thus case statements tend not to check // for them. There are 15 of these in the range 0xff91 ... 0xff9f |
