Author: matt
Date: 2010-11-15 12:12:02 -0800 (Mon, 15 Nov 2010)
New Revision: 7848
Log:
Fixed menu and shortcut handling (STR #2243)

Modified:
   branches/branch-1.1/CHANGES
   branches/branch-1.1/FL/Fl_Menu_Item.H
   branches/branch-1.1/FL/Fl_Widget.H
   branches/branch-1.1/src/Fl_Menu.cxx
   branches/branch-1.1/src/Fl_Menu_Bar.cxx
   branches/branch-1.1/src/fl_shortcut.cxx

Modified: branches/branch-1.1/CHANGES
===================================================================
--- branches/branch-1.1/CHANGES 2010-11-15 19:51:28 UTC (rev 7847)
+++ branches/branch-1.1/CHANGES 2010-11-15 20:12:02 UTC (rev 7848)
@@ -3,6 +3,7 @@
        - Documentation fixes (STR #2410)
        - Fixed mouse wheel related crash in GLUT emulation (STR #2381)
        - Fixed missing architecture flags in OS X build (STR #2303)
+       - Fixed menu and shortcut handling (STR #2243)
 
 CHANGES IN FLTK 1.1.10
 

Modified: branches/branch-1.1/FL/Fl_Menu_Item.H
===================================================================
--- branches/branch-1.1/FL/Fl_Menu_Item.H       2010-11-15 19:51:28 UTC (rev 
7847)
+++ branches/branch-1.1/FL/Fl_Menu_Item.H       2010-11-15 20:12:02 UTC (rev 
7848)
@@ -129,6 +129,7 @@
     int menubar=0) const;
   const Fl_Menu_Item* test_shortcut() const;
   const Fl_Menu_Item* find_shortcut(int *ip=0) const;
+  const Fl_Menu_Item* find_shortcut(int *ip, int require_alt) const;
 
   void do_callback(Fl_Widget* o) const {callback_(o, user_data_);}
   void do_callback(Fl_Widget* o,void* arg) const {callback_(o, arg);}

Modified: branches/branch-1.1/FL/Fl_Widget.H
===================================================================
--- branches/branch-1.1/FL/Fl_Widget.H  2010-11-15 19:51:28 UTC (rev 7847)
+++ branches/branch-1.1/FL/Fl_Widget.H  2010-11-15 20:12:02 UTC (rev 7848)
@@ -190,6 +190,7 @@
   int test_shortcut();
   static char label_shortcut(const char *t);
   static int test_shortcut(const char*);
+  static int test_shortcut(const char*, int require_alt);
   int contains(const Fl_Widget*) const ;
   int inside(const Fl_Widget* o) const {return o ? o->contains(this) : 0;}
 

Modified: branches/branch-1.1/src/Fl_Menu.cxx
===================================================================
--- branches/branch-1.1/src/Fl_Menu.cxx 2010-11-15 19:51:28 UTC (rev 7847)
+++ branches/branch-1.1/src/Fl_Menu.cxx 2010-11-15 20:12:02 UTC (rev 7848)
@@ -899,22 +899,26 @@
   int X, int Y,
   const char* title,
   const Fl_Menu_Item* picked,
-  const Fl_Menu_* but
+  const Fl_Menu_* button
   ) const
 {
   static Fl_Menu_Item dummy; // static so it is all zeros
   dummy.text = title;
-  return pulldown(X, Y, 0, 0, picked, but, title ? &dummy : 0);
+  return pulldown(X, Y, 0, 0, picked, button, title ? &dummy : 0);
 }
 
+const Fl_Menu_Item* Fl_Menu_Item::find_shortcut(int* ip) const {
+  return find_shortcut(ip, 0);
+}
+
 // Search only the top level menu for a shortcut.  Either &x in the
 // label or the shortcut fields are used:
-const Fl_Menu_Item* Fl_Menu_Item::find_shortcut(int* ip) const {
+const Fl_Menu_Item* Fl_Menu_Item::find_shortcut(int* ip, int require_alt) 
const {
   const Fl_Menu_Item* m = first();
   if (m) for (int ii = 0; m->text; m = m->next(), ii++) {
     if (m->activevisible()) {
       if (Fl::test_shortcut(m->shortcut_)
-        || Fl_Widget::test_shortcut(m->text)) {
+        || Fl_Widget::test_shortcut(m->text, require_alt)) {
        if (ip) *ip=ii;
        return m;
       }

Modified: branches/branch-1.1/src/Fl_Menu_Bar.cxx
===================================================================
--- branches/branch-1.1/src/Fl_Menu_Bar.cxx     2010-11-15 19:51:28 UTC (rev 
7847)
+++ branches/branch-1.1/src/Fl_Menu_Bar.cxx     2010-11-15 20:12:02 UTC (rev 
7848)
@@ -65,7 +65,7 @@
     return 1;
   case FL_SHORTCUT:
     if (visible_r()) {
-      v = menu()->find_shortcut();
+      v = menu()->find_shortcut(0, true);
       if (v && v->submenu()) goto J1;
     }
     return test_shortcut() != 0;

Modified: branches/branch-1.1/src/fl_shortcut.cxx
===================================================================
--- branches/branch-1.1/src/fl_shortcut.cxx     2010-11-15 19:51:28 UTC (rev 
7847)
+++ branches/branch-1.1/src/fl_shortcut.cxx     2010-11-15 20:12:02 UTC (rev 
7848)
@@ -221,11 +221,13 @@
   }
 }
 
-int Fl_Widget::test_shortcut(const char *t) {
-  #ifdef WIN32
-  // on MSWindows, users expect shortcuts to work only when the Alt modifier 
is pressed
-  if (Fl::event_state(FL_ALT)==0) return 0;
-  #endif
+int Fl_Widget::test_shortcut(const char *ti) {
+  return test_shortcut(ti, 0);
+}
+
+int Fl_Widget::test_shortcut(const char *t, int 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;
   char c = Fl::event_text()[0];
   if (!c || !t) return 0;
   if (c == label_shortcut(t))

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

Reply via email to