gnucash maint: Bug 798212 - right-click the register down-arrow

Robert Fewell bobit at code.gnucash.org
Mon Jun 21 06:14:30 EDT 2021


Updated	 via  https://github.com/Gnucash/gnucash/commit/abcfa660 (commit)
	from  https://github.com/Gnucash/gnucash/commit/4cff5aa1 (commit)



commit abcfa6600ef51cd1a504d1c77ddaa8a589400c2a
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Mon Jun 21 11:13:31 2021 +0100

    Bug 798212 - right-click the register down-arrow
    
    If the toggle buttons on the register sheet, used for date and transfer
    cells, is clicked with a right mouse the focus would change to the
    first transaction.
    
    To fix add a 'button-press-event' callback to intercept the right mouse
    and also prevent the main register sheet menu from showing when an
    item_edit pop up is showing.

diff --git a/gnucash/register/register-gnome/gnucash-item-edit.c b/gnucash/register/register-gnome/gnucash-item-edit.c
index 1c2d6bf43..b06c238ad 100644
--- a/gnucash/register/register-gnome/gnucash-item-edit.c
+++ b/gnucash/register/register-gnome/gnucash-item-edit.c
@@ -214,6 +214,19 @@ gnc_item_edit_tb_new (GnucashSheet *sheet)
     return GTK_WIDGET(item_edit_tb);
 }
 
+static gboolean
+tb_button_press_cb (G_GNUC_UNUSED GtkWidget *widget, GdkEventButton *event,
+                    G_GNUC_UNUSED gpointer *user_data)
+{
+    /* Ignore double-clicks and triple-clicks */
+    if (event->button == 3 && event->type == GDK_BUTTON_PRESS)
+    {
+        // block a right click
+        return TRUE;
+    }
+    return FALSE;
+}
+
 /*
  * Returns the coordinates for the editor bounding box
  */
@@ -883,14 +896,19 @@ gnc_item_edit_get_button_width (GncItemEdit *item_edit)
 static gboolean
 button_press_cb (GtkWidget *widget, GdkEventButton *event, gpointer *pointer)
 {
-    GnucashSheet *sheet = GNUCASH_SHEET(pointer);
+    GncItemEdit *item_edit = GNC_ITEM_EDIT(pointer);
+    GnucashSheet *sheet = item_edit->sheet;
 
     /* Ignore double-clicks and triple-clicks */
     if (event->button == 3 && event->type == GDK_BUTTON_PRESS)
     {
-        // This is a right click event so over ride entry menu and
-        // display main register popup menu.
-        g_signal_emit_by_name (sheet->reg, "show_popup_menu");
+        if (!item_edit->show_popup)
+        {
+            // This is a right click event so over ride entry menu and
+            // display main register popup menu if no item_edit popup
+            // is showing.
+            g_signal_emit_by_name (sheet->reg, "show_popup_menu");
+        }
         return TRUE;
     }
     return FALSE;
@@ -945,7 +963,7 @@ gnc_item_edit_new (GnucashSheet *sheet)
     // This call back intercepts the mouse button event so the main
     // register popup menu can be displayed instead of the entry one.
     g_signal_connect (item_edit->editor, "button-press-event",
-                      G_CALLBACK(button_press_cb), sheet);
+                      G_CALLBACK(button_press_cb), item_edit);
 
     /* Create the popup button
        It will only be displayed when the cell being edited provides
@@ -960,6 +978,11 @@ gnc_item_edit_new (GnucashSheet *sheet)
     gtk_container_add (GTK_CONTAINER(item_edit->popup_toggle.ebox),
                        item_edit->popup_toggle.tbutton);
 
+    // This call back intercepts the right mouse button event to stop the
+    // gnucash_sheet_button_press_event from running.
+    g_signal_connect (item_edit->popup_toggle.ebox, "button-press-event",
+                      G_CALLBACK(tb_button_press_cb), NULL);
+
     gtk_box_pack_start (GTK_BOX(item_edit), item_edit->popup_toggle.ebox, FALSE, FALSE, 0);
     gtk_widget_show_all (GTK_WIDGET(item_edit));
     g_signal_connect (G_OBJECT(item_edit), "destroy",



Summary of changes:
 .../register/register-gnome/gnucash-item-edit.c    | 33 ++++++++++++++++++----
 1 file changed, 28 insertions(+), 5 deletions(-)



More information about the gnucash-changes mailing list