summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Melcher <fltk@matthiasm.com>2011-01-09 12:56:50 +0000
committerMatthias Melcher <fltk@matthiasm.com>2011-01-09 12:56:50 +0000
commitd96789d93195cad9f15b63d72b26295b746e4a39 (patch)
tree56688db4384bc39f3c4d70f6321abb0a28cd8f3b /src
parent712554e3b0a4c0017b841d4c92a9fe4b162759d1 (diff)
STR 1760: using the alt modifier on OS X to access menubar accelerators.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8223 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
-rw-r--r--src/fl_shortcut.cxx14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/fl_shortcut.cxx b/src/fl_shortcut.cxx
index c2955152c..2305545f6 100644
--- a/src/fl_shortcut.cxx
+++ b/src/fl_shortcut.cxx
@@ -344,9 +344,21 @@ int Fl_Widget::test_shortcut(const char *t, const bool require_alt) {
// 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;
}