Debugging runtime warnings from gtk_menu_popup_at_rect

I’m trying to use the gtk_menu_popup_at_rect function. Here is a simplified version of the code I’ve written…

    // declare a menu and add an item to it
    GtkWidget *menu = gtk_menu_new();
    GtkWidget *item = gtk_menu_item_new_with_label("foo");
    gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);

    GdkRectangle rect;
    rect.x = 0;
    rect.y = 0;
    rect.width = 0;
    rect.height = 0;

    // trigger the popup

This displays the menu, but there are a few issues.

  1. The popup is not focused initially. Clicking the popup initially just gives it focus, only after that can you interact with it normally. That isn’t the desired behavior. It seems like there is a procedure that im not aware of. I tried calling gtk_widget_grab_focus first but it had no effect.
  2. I get these two runtime warnings which i assume are related…
Gtk-WARNING **: 10:53:16.743: no trigger event for menu popup
Gdk-WARNING **: 10:53:16.824: Tried to map a popup with a non-top most parent

It’s too simplified… I think.

Ideally it should be a complete standalone example that anyone interested in helping can easily compile and run, which this is not.

It doesn’t even show us what “window” actually refers to.

Edit: Yes a standalone is ideal, i think it may be possible to produce one. For now, this is the window…

 GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL);

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.