Author: matt
Date: 2011-01-09 04:56:50 -0800 (Sun, 09 Jan 2011)
New Revision: 8223
Log:
STR 1760: using the alt modifier on OS X to access menubar accelerators.

Modified:
   branches/branch-1.3/src/fl_shortcut.cxx

Modified: branches/branch-1.3/src/fl_shortcut.cxx
===================================================================
--- branches/branch-1.3/src/fl_shortcut.cxx     2011-01-09 08:34:13 UTC (rev 
8222)
+++ branches/branch-1.3/src/fl_shortcut.cxx     2011-01-09 12:56:50 UTC (rev 
8223)
@@ -344,9 +344,21 @@
   // for menubars etc. shortcuts must work only if the Alt modifier is pressed
   if (require_alt && Fl::event_state(FL_ALT)==0) return 0;
   unsigned int c = fl_utf8decode(Fl::event_text(), 
Fl::event_text()+Fl::event_length(), 0);
+#ifdef __APPLE__
+  // this line makes underline shortcuts work the same way they do on MSWindow
+  // and Linux. 
+  if (c && Fl::event_state(FL_ALT)) 
+    c = Fl::event_key();
+#endif
   if (!c) return 0;
-  if (c == label_shortcut(t))
+  unsigned int ls = label_shortcut(t);
+  if (c == ls)
     return 1;
+#ifdef __APPLE__
+  // On OS X, we need to simulate the upper case keystroke as well
+  if (Fl::event_state(FL_ALT) && c<128 && isalpha(c) && 
(unsigned)toupper(c)==ls)
+    return 1;
+#endif
   return 0;
 }
 

_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit

Reply via email to