now added fix suggested by Ioannis to make menus work when an entryfunc
[freeglut] / src / fg_menu.c
index 0c6c64e..65ec674 100644 (file)
@@ -29,6 +29,7 @@
 #include <GL/freeglut.h>
 #include "fg_internal.h"
 
+
 /* -- DEFINITIONS ---------------------------------------------------------- */
 
 /*
@@ -403,7 +404,7 @@ static void fghDisplayMenuBox( SFG_Menu* menu )
 
 /*
  * Private static function to set the parent window of a submenu and all
- * of its submenus
+ * of its submenus.
  */
 static void fghSetMenuParentWindow( SFG_Window *window, SFG_Menu *menu )
 {
@@ -620,11 +621,12 @@ GLboolean fgCheckActiveMenu ( SFG_Window *window, int button, GLboolean pressed,
             /*
              * Outside the menu, deactivate if it's a downclick
              *
-             * XXX This isn't enough.  A downclick outside of
-             * XXX the interior of our freeglut windows should also
-             * XXX deactivate the menu.  This is more complicated.
+             * A downclick outside of the interior of our freeglut windows
+             * is dealt with in the WM_KILLFOCUS handler of fgPlatformWindowProc
              */
+        {
             fgDeactivateMenu( window->ActiveMenu->ParentWindow );
+        }
 
         /*
          * XXX Why does an active menu require a redisplay at
@@ -659,12 +661,13 @@ GLboolean fgCheckActiveMenu ( SFG_Window *window, int button, GLboolean pressed,
 void fgDeactivateMenu( SFG_Window *window )
 {
     SFG_Window *parent_window = NULL;
-
-    /* Check if there is an active menu attached to this window... */
-    SFG_Menu* menu = window->ActiveMenu;
+    SFG_Menu* menu;
     SFG_MenuEntry *menuEntry;
 
     /* Did we find an active window? */
+    freeglut_return_if_fail( window );
+    /* Check if there is an active menu attached to this window... */
+    menu = window->ActiveMenu;
     freeglut_return_if_fail( menu );
 
     parent_window = menu->ParentWindow;
@@ -689,7 +692,7 @@ void fgDeactivateMenu( SFG_Window *window )
     {
         menuEntry->IsActive = GL_FALSE;
 
-        /* Is that an active submenu by any case? */
+        /* Is that an active submenu by any chance? */
         if( menuEntry->SubMenu )
             fghDeactivateSubMenu( menuEntry );
     }