popup menu on GtkText



My app uses button-3 popup menus in many of its windows.  Mostly the
popups appear against a background of lists, but I recently added a
popup for a text widget.

I'm currently trying to maintain both GTK 1.2 and GTK 2.0 versions of
my program.  The new text window popup works fine in 2.0 (over a
GtkTextView), but doesn't work right in 1.2 (over a GtkText). In the
latter case, it takes two mouse actions to accomplish what one should
do.  I.e.

* right-click pops up the menu. OK.
* moving the mouse on the popup highlights menu items. OK.
* clicking on a menu item does nothing
* a _second_ click on a menu item performs the action
  associated with the menu item

I'm connecting the popup with:

  gkt_signal_connect_object (GTK_OBJECT(text), "button_press_event",
    GTK_SIGNAL_FUNC(popup_menu_handler),
      GTK_OBJECT(popup));

where "text" was made with gtk_text_new() and "popup" is a GtkMenu.

The callback is like:

gint popup_menu_handler (GtkWidget *widget, GdkEvent *event)
{
    GtkMenu *menu = GTK_MENU (widget);

    if (event->type == GDK_BUTTON_PRESS) {
        GdkEventButton *event_button = (GdkEventButton *) event;

        if (event_button->button == 3) {
            gtk_menu_popup (menu, NULL, NULL, NULL, NULL,
                            event_button->button, event_button->time);
            return TRUE;
        }
    }
    return FALSE;
}

Can anyone tell me what I'm doing wrong?  Thanks.

Allin Cottrell.





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]