gtk_item_factory_popup() question



I have a top level window in which is a container which holds a table.
Attached to the table is a GtkWidget into which I've loaded some text
using gtk_text_insert(). When I run the app I can select the text by dragging with the mouse and then paste it elsewhere perfectly OK, which is the main purpose of the display.

Then I added a popup menu.  Now if I call up the menu, then dismiss it,
whether or not I choose any of the menu entries, the text in my main
display behaves differently.

When I drag my mouse across it, instead of the background to the selected text going blue, it goes mid-grey, and the text is not copied to the clipboard.

It's not been made insensitive - I tried coding that just to see what it
would do and the whole display is greyed out as you'd expect.

Everything else seems to work OK - the title bar is still blue, so in focus, the vertical scroll bar works fine, exiting is OK. If it was a focus issue then I'd expect the text to grab focus when I clicked in the display, but that makes no difference.

So it seems to me to be the line that actually displays the popup menu, gtk_item_factory_popup(), that's causing my problem, but I have no idea what's actually wrong.

Here are the functions that construct and then display the menu. I'm quite happy to send much more code, but hope this will be enough.

Hope someone can help
Rob

static void createPopupMenu(struct GexEditor *editor)
{
  GtkAccelGroup  *accel_group;
  GtkItemFactoryEntry menu_items[] = {
    {"/_Quit"      ,"<control>Q", menuQuit     , 0, NULL},
    {"/_Help"      ,"<control>H", help         , 0, NULL},
    {"/_Print"     ,"<control>P", editPrint    , 0, NULL},
    {"/_Select All","<control>A", editSelectAll, 0, NULL},
  };
  gint nmenu_items = sizeof(menu_items) / (sizeof (menu_items[0]));

  accel_group = gtk_accel_group_new();

item_factory = gtk_item_factory_new(GTK_TYPE_MENU, "<popup>", accel_group);

gtk_item_factory_create_items(item_factory, nmenu_items, menu_items, NULL);

  gtk_accel_group_attach(accel_group, GTK_OBJECT(editor->window));

  return;
}



static gint ButtonPressCallback(GtkWidget *widget,
                                GdkEventButton *event,
                                gpointer callback_data)
{
  gint x, y;

  if (event->button == 3)  /* ie ignore left and middle buttons */
    {
      /* find out where the mouse pointer is positioned */
      gdk_window_get_origin(widget->window, &x, &y);

      /* pop up the menu where the mouse pointer is */
      gtk_item_factory_popup(item_factory,
                             event->x + x, event->y + y,
                             event->button, event->time);

    }
  else
    {
      gpointer editor;

      editor = gtk_object_get_data(GTK_OBJECT(item_factory), "editor");
gtk_editable_select_region(GTK_EDITABLE(((struct GexEditor*)editor)->text), 0, 0);
    }

  return 0;
}


--
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Just self-replicating, compartmentalised redox chemistry, really.
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Rob Clack                        Acedb Development,  Informatics Group
 email: rnc sanger ac uk                Wellcome Trust Sanger Institute
 Tel: +44 1223 494780                   Wellcome Trust Genome Campus
 Fax: +44 1223 494919                   Hinxton  Cambridge    CB10 1SA





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