diff options
| author | Matthias Melcher <fltk@matthiasm.com> | 2002-10-30 01:01:53 +0000 |
|---|---|---|
| committer | Matthias Melcher <fltk@matthiasm.com> | 2002-10-30 01:01:53 +0000 |
| commit | 36656517e6646a0bd8c287040ec57438cc686890 (patch) | |
| tree | 642ad8f01bd6920a8da183259821bcb2aa91270e /src | |
| parent | a5131e195974d6b61a9763e2bca9dc02bf36e474 (diff) | |
Unswapped MacOS modifier keys. event_key and event_text should return
the expected values now.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@2715 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
| -rw-r--r-- | src/Fl_mac.cxx | 42 | ||||
| -rw-r--r-- | src/fl_shortcut.cxx | 6 |
2 files changed, 37 insertions, 11 deletions
diff --git a/src/Fl_mac.cxx b/src/Fl_mac.cxx index 59044019a..d521ee272 100644 --- a/src/Fl_mac.cxx +++ b/src/Fl_mac.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_mac.cxx,v 1.1.2.35 2002/10/29 19:23:55 matthiaswm Exp $" +// "$Id: Fl_mac.cxx,v 1.1.2.36 2002/10/30 01:01:52 matthiaswm Exp $" // // MacOS specific code for the Fast Light Tool Kit (FLTK). // @@ -860,9 +860,9 @@ static void mods_to_e_state( UInt32 mods ) { long state = 0; if ( mods & kEventKeyModifierNumLockMask ) state |= FL_NUM_LOCK; - if ( mods & cmdKey ) state |= FL_CTRL; + if ( mods & cmdKey ) state |= FL_META; if ( mods & (optionKey|rightOptionKey) ) state |= FL_ALT; - if ( mods & (controlKey|rightControlKey) ) state |= FL_META; + if ( mods & (controlKey|rightControlKey) ) state |= FL_CTRL; if ( mods & (shiftKey|rightShiftKey) ) state |= FL_SHIFT; if ( mods & alphaLock ) state |= FL_CAPS_LOCK; Fl::e_state = ( Fl::e_state & 0xff000000 ) | state; @@ -875,18 +875,36 @@ static void mods_to_e_state( UInt32 mods ) */ static void mods_to_e_keysym( UInt32 mods ) { - if ( mods & cmdKey ) Fl::e_keysym = FL_Control_L; + if ( mods & cmdKey ) Fl::e_keysym = FL_Meta_L; else if ( mods & kEventKeyModifierNumLockMask ) Fl::e_keysym = FL_Num_Lock; else if ( mods & optionKey ) Fl::e_keysym = FL_Alt_L; else if ( mods & rightOptionKey ) Fl::e_keysym = FL_Alt_R; - else if ( mods & controlKey ) Fl::e_keysym = FL_Meta_L; - else if ( mods & rightControlKey ) Fl::e_keysym = FL_Meta_R; + else if ( mods & controlKey ) Fl::e_keysym = FL_Control_L; + else if ( mods & rightControlKey ) Fl::e_keysym = FL_Control_R; else if ( mods & shiftKey ) Fl::e_keysym = FL_Shift_L; else if ( mods & rightShiftKey ) Fl::e_keysym = FL_Shift_R; else if ( mods & alphaLock ) Fl::e_keysym = FL_Caps_Lock; else Fl::e_keysym = 0; } +/** + * convert the keyboard return code into the symbol on the keycaps + */ +static unsigned short keycode_to_sym( UInt32 keyCode, UInt32 mods, unsigned short deflt ) +{ + static Ptr map = 0; + UInt32 state = 0; + if (!map) { + map = (Ptr)GetScriptManagerVariable(smKCHRCache); + if (!map) { + long kbID = GetScriptManagerVariable(smKeyScript); + map = *GetResource('KCHR', kbID); + } + } + if (map) + return KeyTranslate(map, keyCode|mods, &state ); + return deflt; +} /** * handle carbon keyboard events @@ -917,7 +935,15 @@ pascal OSStatus carbonKeyboardHandler( EventHandlerCallRef nextHandler, EventRef // fall through case kEventRawKeyUp: if ( !sendEvent ) sendEvent = FL_KEYUP; - sym = macKeyLookUp[ keyCode & 0x7f ]; + // if the user pressed alt/option, event_key should have the keycap, but event_text should generate the international symbol + if ( isalpha(key) ) + sym = tolower(key); + else if ( Fl::e_state&FL_CTRL && key<32 ) + sym = key+96; + else if ( Fl::e_state&FL_ALT ) + sym = keycode_to_sym( keyCode & 0x7f, 0, macKeyLookUp[ keyCode & 0x7f ] ); // find the keycap of this key + else + sym = macKeyLookUp[ keyCode & 0x7f ]; Fl::e_keysym = sym; if ( keyCode==0x4c ) key=0x0d; if ( ( (sym>=FL_KP) && (sym<=FL_KP_Last) ) || ((sym&0xff00)==0) || (sym==FL_Tab) ) { @@ -1724,6 +1750,6 @@ void Fl::paste(Fl_Widget &receiver, int clipboard) { // -// End of "$Id: Fl_mac.cxx,v 1.1.2.35 2002/10/29 19:23:55 matthiaswm Exp $". +// End of "$Id: Fl_mac.cxx,v 1.1.2.36 2002/10/30 01:01:52 matthiaswm Exp $". // diff --git a/src/fl_shortcut.cxx b/src/fl_shortcut.cxx index ce7ce0c3c..c4fad7b0d 100644 --- a/src/fl_shortcut.cxx +++ b/src/fl_shortcut.cxx @@ -1,5 +1,5 @@ // -// "$Id: fl_shortcut.cxx,v 1.4.2.9.2.7 2002/08/09 03:17:30 easysw Exp $" +// "$Id: fl_shortcut.cxx,v 1.4.2.9.2.8 2002/10/30 01:01:53 matthiaswm Exp $" // // Shortcut support routines for the Fast Light Tool Kit (FLTK). // @@ -115,7 +115,7 @@ const char * fl_shortcut_label(int shortcut) { static char buf[20]; char *p = buf; if (!shortcut) {*p = 0; return buf;} -#ifdef __APPLE__ +#ifdef UNUSED__APPLE__UNUSED // \todo Mac : we might want to change the symbols for Mac users - consider drawing Apple Symbols... . if (shortcut & FL_SHIFT) {strcpy(p,"shift+"); p += 6;} //: Mac hollow up arrow if (shortcut & FL_META) {strcpy(p,"ctrl+"); p += 5;} //: Mac 'cotrol' @@ -200,5 +200,5 @@ int Fl_Widget::test_shortcut() { } // -// End of "$Id: fl_shortcut.cxx,v 1.4.2.9.2.7 2002/08/09 03:17:30 easysw Exp $". +// End of "$Id: fl_shortcut.cxx,v 1.4.2.9.2.8 2002/10/30 01:01:53 matthiaswm Exp $". // |
