+ SFG_Enumerator enumerator;
+
+ /* This is easy and makes use of the menus enumeration defined above */
+ enumerator.found = GL_FALSE;
+ enumerator.data = (void *)&menuID;
+ fgEnumMenus( fghcbMenuByID, &enumerator );
+
+ if( enumerator.found )
+ return( SFG_Menu *) enumerator.data;
+
+ return NULL;
+}
+
+/*
+ * A static helper function to look for an active menu
+ */
+static void fghcbGetActiveMenu( SFG_Menu *menu,
+ SFG_Enumerator *enumerator )
+{
+ if ( enumerator->found )
+ return;
+
+ /* Check the menu's is active */
+ if( menu->IsActive )
+ {
+ enumerator->found = GL_TRUE;
+ enumerator->data = menu;
+
+ return;
+ }
+}
+
+/*
+ * Returns active menu, if any. Assumption: only one menu active throughout application at any one time.
+ * This is false when a submenu is also open.
+ * This is easier than fgWindowByXXX as all menus are placed in one doubly linked list...
+ */
+SFG_Menu* fgGetActiveMenu( )
+{
+ SFG_Enumerator enumerator;
+
+ /* This is easy and makes use of the menus enumeration defined above */
+ enumerator.found = GL_FALSE;
+ fgEnumMenus( fghcbGetActiveMenu, &enumerator );
+
+ if( enumerator.found )
+ return( SFG_Menu *) enumerator.data;