ui/gtk/menu.c

changeset 1256
da0899b1699d
parent 1251
a1623c48c998
child 1257
e201fe56f890
--- a/ui/gtk/menu.c	Sun Sep 13 11:50:14 2026 +0200
+++ b/ui/gtk/menu.c	Sun Sep 13 14:30:34 2026 +0200
@@ -46,6 +46,13 @@
 #include <cx/array_list.h>
 #include <cx/printf.h>
 
+static void contextmenu_handler(GtkWidget *widget) {
+    UiContextMenuPopupCallback *cb = g_object_get_data(G_OBJECT(widget), "ui_contextmenu_handler");
+    if(cb && cb->callback) {
+        cb->callback(NULL, cb->userdata);
+    }
+}
+
 #if GTK_MAJOR_VERSION <= 3
 
 static ui_menu_add_f createMenuItem[] = {
@@ -502,6 +509,7 @@
 }
 
 void ui_contextmenu_popup(UIMENU menu, GtkWidget *widget, int x, int y) {
+    contextmenu_handler(widget);
     gtk_widget_show_all(GTK_WIDGET(menu));
 #if GTK_MAJOR_VERSION >= 3 && GTK_MINOR_VERSION >= 16
     gtk_menu_popup_at_pointer(menu, NULL);
@@ -1015,6 +1023,7 @@
 }
 
 void ui_contextmenu_popup(UIMENU menu, UIWIDGET widget, int x, int y) {
+    contextmenu_handler(widget);
     gtk_popover_set_pointing_to(GTK_POPOVER(menu), &(GdkRectangle){ x, y, 0, 0 });
     gtk_popover_popup(GTK_POPOVER(menu));
 }

mercurial