fix in fgUpdateMenuHighlight: clicked entry is always the active entry already, so no while loop. also, ignore clicks on a submenu's parent entry

git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@1606 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
dcnieho 2013-04-06 10:14:41 +00:00
parent 4c1b2f7f71
commit 23e0e585ef

View File

@ -265,7 +265,7 @@ static GLboolean fghCheckMenuStatus( SFG_Menu* menu )
} }
/* Activate it because its parent entry is active */ /* Activate it because its parent entry is active */
menuEntry->SubMenu->IsActive = GL_TRUE; /* XXX Do we need this? */ menuEntry->SubMenu->IsActive = GL_TRUE;
} }
/* Report back that we have caught the menu cursor */ /* Report back that we have caught the menu cursor */
@ -546,8 +546,7 @@ static void fghActivateMenu( SFG_Window* window, int button )
/* /*
* Update Highlight states of the menu * Update Highlight states of the menu
* * NB: Current mouse position is in menu->Window->State.MouseX/Y
* Current mouse position is in menu->Window->State.MouseX/Y.
*/ */
void fgUpdateMenuHighlight ( SFG_Menu *menu ) void fgUpdateMenuHighlight ( SFG_Menu *menu )
{ {
@ -597,17 +596,13 @@ GLboolean fgCheckActiveMenu ( SFG_Window *window, int button, GLboolean pressed,
* window to the window whose menu this is * window to the window whose menu this is
*/ */
SFG_Window *save_window = fgStructure.CurrentWindow; SFG_Window *save_window = fgStructure.CurrentWindow;
SFG_Menu *save_menu = fgStructure.CurrentMenu, *active_menu = window->ActiveMenu; SFG_Menu *save_menu = fgStructure.CurrentMenu, *active_menu = window->ActiveMenu; /* active menu is always the one with the mouse in it, due to fghCheckMenuStatus */
SFG_MenuEntry *active_entry = active_menu->ActiveEntry; SFG_MenuEntry *active_entry = active_menu->ActiveEntry; /* currently highlighted item -> must be the one that was just clicked */
SFG_Window *parent_window = window->ActiveMenu->ParentWindow; SFG_Window *parent_window = window->ActiveMenu->ParentWindow;
/* get clicked entry */ /* ignore clicks on the submenu entry */
while (active_entry->SubMenu) if (!active_entry->SubMenu)
{ {
active_menu = active_entry->SubMenu;
active_entry = active_menu->ActiveEntry;
}
fgSetWindow( parent_window ); fgSetWindow( parent_window );
fgStructure.CurrentMenu = active_menu; fgStructure.CurrentMenu = active_menu;
@ -618,6 +613,7 @@ GLboolean fgCheckActiveMenu ( SFG_Window *window, int button, GLboolean pressed,
/* Restore the current window and menu */ /* Restore the current window and menu */
fgSetWindow( save_window ); fgSetWindow( save_window );
fgStructure.CurrentMenu = save_menu; fgStructure.CurrentMenu = save_menu;
}
is_clicked = GL_TRUE; /* Don't reopen... */ is_clicked = GL_TRUE; /* Don't reopen... */
} }
@ -748,7 +744,7 @@ void fghCalculateMenuBoxSize( void )
/* /*
* If the entry is a submenu, then it needs to be wider to * If the entry is a submenu, then it needs to be wider to
* accomodate the arrow. JCJ 31 July 2003 * accommodate the arrow.
*/ */
if (menuEntry->SubMenu) if (menuEntry->SubMenu)
menuEntry->Width += glutBitmapLength( menuEntry->Width += glutBitmapLength(