From: H.G.Muller Date: Mon, 7 Mar 2016 15:16:17 +0000 (+0100) Subject: Allow use of context menu in text memos GTK X-Git-Url: http://winboard.nl/cgi-bin?p=xboard.git;a=commitdiff_plain;h=eca734a86610900053cd02af3e78d7983fe3bb40 Allow use of context menu in text memos GTK Attaching a user handler for button3 events to text memos would suppress the normal context menu, so you could copy/paste in those only through the keyboard. Now a button3 event while there is a non-empty selection, or through a click behind all text, will pop up the normal context menu. --- diff --git a/gtk/xoptions.c b/gtk/xoptions.c index d3a8835..0737c79 100644 --- a/gtk/xoptions.c +++ b/gtk/xoptions.c @@ -683,10 +683,10 @@ MemoEvent(GtkWidget *widget, GdkEvent *event, gpointer gdata) } if(memo->value == 250 // kludge to recognize ICS Console and Chat panes && gtk_text_buffer_get_selection_bounds(memo->handle, NULL, NULL) ) { -printf("*** selected\n"); gtk_text_buffer_get_selection_bounds(memo->handle, &start, &end); // only return selected text - index = -1; // kludge to indicate omething was selected + index = -1; // kludge to indicate something was selected } else { + if(abs(button) == 3 && gtk_text_buffer_get_selection_bounds(memo->handle, NULL, NULL)) return FALSE; // normal context menu // GTK_TODO: is this really the most efficient way to get the character at the mouse cursor??? gtk_text_view_window_to_buffer_coords(GTK_TEXT_VIEW(widget), GTK_TEXT_WINDOW_WIDGET, w, h, &x, &y); gtk_text_view_get_iter_at_location(GTK_TEXT_VIEW(widget), &start, x, y); @@ -699,7 +699,7 @@ printf("*** selected\n"); } /* get text from textbuffer */ val = gtk_text_buffer_get_text (memo->handle, &start, &end, FALSE); - break; + if(strlen(val) != index) break; // if we clicked behind all text, fall through to do default action default: return FALSE; // should not happen }