diff options
| author | Matthias Melcher <fltk@matthiasm.com> | 2006-04-19 03:00:26 +0000 |
|---|---|---|
| committer | Matthias Melcher <fltk@matthiasm.com> | 2006-04-19 03:00:26 +0000 |
| commit | 1df4a9fb4a222b160c01e115539d983434f5a152 (patch) | |
| tree | 2a34f353c253c1c62fe3e0f9f7ef4c9c7c39b9df /src/Fl_mac.cxx | |
| parent | c9908d97e3ab4e4d0cd87435c52aea88a5a4abc0 (diff) | |
STR #1195: It was not possible to enter a whole range of characters on Mac OS X, including umlauts, etc. . The changes in this patch should not only allow the FLTK way of composing characters, but also support the Mac way of composing including the dead-key preview.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@4984 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/Fl_mac.cxx')
| -rw-r--r-- | src/Fl_mac.cxx | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/Fl_mac.cxx b/src/Fl_mac.cxx index 4693f8316..b8df6264b 100644 --- a/src/Fl_mac.cxx +++ b/src/Fl_mac.cxx @@ -1067,10 +1067,27 @@ pascal OSStatus carbonKeyboardHandler( { case kEventRawKeyDown: case kEventRawKeyRepeat: + // When the user presses a "dead key", no information is send about + // which dead key symbol was created. So we need to trick Carbon into + // giving us the code by sending a "space" after the "dead key". + if (key==0) { + UInt32 ktState = 0; + KeyboardLayoutRef klr; + KLGetCurrentKeyboardLayout(&klr); + const void *kchar = 0; KLGetKeyboardLayoutProperty(klr, kKLKCHRData, &kchar); + KeyTranslate(kchar, (mods&0xff00) | keyCode, &ktState); // send the dead key + key = KeyTranslate(kchar, 0x31, &ktState); // fake a space key press + Fl::e_state |= 0x40000000; // mark this as a dead key + } else { + Fl::e_state &= 0xbfffffff; // clear the deadkey flag + } sendEvent = FL_KEYBOARD; // fall through case kEventRawKeyUp: - if ( !sendEvent ) sendEvent = FL_KEYUP; + if ( !sendEvent ) { + sendEvent = FL_KEYUP; + Fl::e_state &= 0xbfffffff; // clear the deadkey flag + } // if the user pressed alt/option, event_key should have the keycap, // but event_text should generate the international symbol if ( isalpha(key) ) |
