From 71fc940b34352bbc4cf5dd86ef91cfe6b94bf7ad Mon Sep 17 00:00:00 2001 From: H.G.Muller Date: Thu, 10 Mar 2016 10:41:07 +0100 Subject: [PATCH] Fix popdown of menus on help click Because menus by default also react to button3 clicks, using those clicks for help popup needs to suppress the default action. But this action was also reponsible for the popdown of the menu, so that it stayed up, covering the help dialog. Now we do allow the default action, but flag to the generic menu handler that it should not execute the menu function. --- dialogs.h | 1 + gtk/xoptions.c | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletions(-) diff --git a/dialogs.h b/dialogs.h index 9468d52..a2f5979 100644 --- a/dialogs.h +++ b/dialogs.h @@ -199,6 +199,7 @@ void LoadOptionsPopUp P((DialogClass parent)); void GameListOptionsPopUp P((DialogClass parent)); void RefreshColor P((int source, int n)); void SendString P((char *p)); +void DisplayHelp P((char *name)); // in ngamelist.c int GameListClicks P((int direction)); diff --git a/gtk/xoptions.c b/gtk/xoptions.c index a3a54ea..5c6f91f 100644 --- a/gtk/xoptions.c +++ b/gtk/xoptions.c @@ -370,14 +370,18 @@ SetIconName (DialogClass dlg, char *name) #endif } +int menuBlock = FALSE; + static gboolean HelpEvent(GtkWidget *widget, GdkEventButton *event, gpointer gdata) { // intercept button3 clicks to pop up help // Option *opt = (Option *) gdata; char *msg = (char *) gdata; + int menu = (event->type == GDK_BUTTON_RELEASE); // only menu items trigger help on release if(event->button != 3) return FALSE; DisplayHelp(msg); - return TRUE; + menuBlock = menu; // flag menu execution should be suppressed + return !menu; } void ComboSelect(GtkWidget *widget, gpointer addr) @@ -423,6 +427,7 @@ MenuSelect (gpointer addr) // callback for all combo items int i = ((intptr_t)addr)>>16 & 255; // option number int j = 0xFFFF & (intptr_t) addr; + if(menuBlock) { menuBlock = FALSE; return; } // was help click only values[i] = j; // store selected value in Option struct, for retrieval at OK ((ButtonCallback*) opt[i].target)(i); } -- 1.7.0.4