summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2024-10-19 09:14:45 +0200
committerManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2024-10-19 09:14:45 +0200
commit6ea450407b3d9e5d6f2731ee6f89b1000e1f3c22 (patch)
tree30590921e229ce5e32dc5279719a5b372859179f
parent04c8dd9d268a80a478b6bded35afc4e120c9ae45 (diff)
Windows: process the +-containing key used with Ctrl in cross-platform way
-rw-r--r--src/Fl_win32.cxx40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/Fl_win32.cxx b/src/Fl_win32.cxx
index adaf598c6..fe3ff5e9b 100644
--- a/src/Fl_win32.cxx
+++ b/src/Fl_win32.cxx
@@ -1573,6 +1573,46 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar
#endif
}
Fl::e_text = buffer;
+
+ // Kludge to process the +-containing key in cross-platform way when used with Ctrl
+/* Table of how Windows processes the '+'-containing key by keyboard layout
+ key virtual
+content key keyboard layout
+ =|+ 0xbb US/UK/Fr/Arabic/Chinese/Hebrew/Brazil/Russian/Vietnam/Japan/Korean/Persian
+ +|* 0xbb German/Spanish/Italy/Greek/Portugal
+ +|? 0xbb Swedish/Finish/Norway
+ +|± 0xbb Dutch
+ 1|+ '1' Swiss/Luxemburg
+ 3|+ '3' Hungarian
+ 4|+ '4' Turkish
+*/
+ if (Fl::e_state & FL_CTRL) { // extra processing necessary only when Ctrl is down
+ int vk_plus_key = (VkKeyScanA('+') & 0xff); // virtual key of '+'-containing key
+ bool plus_shift_pos = ((VkKeyScanA('+') & 0x100) != 0); // true means '+' in shifted position
+ int plus_other_char; // the other char on same key as '+'
+ if (plus_shift_pos) plus_other_char = ms2fltk(vk_plus_key, 0);
+ else if ((VkKeyScanA('*') & 0xff) == vk_plus_key) plus_other_char = '*'; // German
+ else if ((VkKeyScanA('?') & 0xff) == vk_plus_key) plus_other_char = '?'; // Swedish
+ else if ((VkKeyScanW(L'±') & 0xff) == vk_plus_key) plus_other_char = L'±'; // Dutch
+ else plus_other_char = '='; // fallback
+//fprintf(stderr, "plus_shift_pos=%d plus_other_char='%c' vk+=0x%x\n", plus_shift_pos,
+// plus_other_char, vk_plus_key);
+ if ( (vk_plus_key == 0xbb && Fl::e_keysym == '=') || // the '+'-containing key is down
+ (plus_shift_pos && Fl::e_keysym == plus_other_char) ) {
+ Fl::e_keysym = (plus_shift_pos ? plus_other_char : '+');
+ static char plus_other_char_utf8[4];
+ int lutf8 = fl_utf8encode(plus_other_char, plus_other_char_utf8);
+ plus_other_char_utf8[lutf8] = 0;
+ if (plus_shift_pos) {
+ Fl::e_text = ( (Fl::e_state & FL_SHIFT) ? (char*)"+" : plus_other_char_utf8 );
+ } else {
+ Fl::e_text = ( (Fl::e_state & FL_SHIFT) ? plus_other_char_utf8 : (char*)"+" );
+ }
+ Fl::e_length = strlen(Fl::e_text);
+ }
+ }
+ // end of processing of the +-containing key
+
if (lParam & (1 << 31)) { // key up events.
if (Fl::handle(FL_KEYUP, window))
return 0;