Re: Can't select text after popup menu



Hi Robert,

Lookup the GTK 1.2 tutorial, and check the chapter on "19. Managing
Selections". There is explains the difference between the different ways
of copying texts. Basically, if you want to insure that a text is copied
to the clipboard (to be used with cut&paste), you'll have to invoke some
explicit function like:

  gtk_editable_copy_clipboard(GTK_EDITABLE(w));

The other way, with button 2, is implicit, and you do not have to program
anything to do that, it's all done magically by the widgets (like
gtk_entry) that know about it.

John

On Mon, 16 Jun 2003 10:13:46 +0100
Rob Clack <rnc sanger ac uk> wrote:

I posted this question last week, but think I described it badly, so am 
having another go.

In my window I display some text, which I can select by dragging across 
it with the mouse.  The background goes blue and the text is in the 
clipboard.  So far so good.

If I then display and dismiss a popup menu, when I drag the mouse across

the text the background goes grey instead of blue and the text is not in

the clipboard.

So something about my popup menu is breaking my ability to select the 
text.

Trouble is, I'm so new to gtk I don't know how to track this down.  The 
books I'm working from don't help and I can't find anything in the
archives.

Below are the functions that build and display the menu, and the 
fragment from main() that sets it all up.

Hope someone can help.
tvm
Rob Clack


static void createPopupMenu(GtkWidget *window)
{
   GtkAccelGroup  *accel_group;
   static GtkItemFactoryEntry menu_items[] = {
     {"/_Quit", "<control>Q", Quit , 0, NULL},
     {"/_Help", "<control>H", Help , 0, NULL},
     {"/_Print","<control>P", Print, 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(window));
}



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

   if (event->button == 3)
     {
       gdk_window_get_origin(widget->window, &x, &y);
       gtk_item_factory_popup(item_factory,
                           event->x + x, event->y + y,
                           event->button, event->time);

     }
   return;
}


int main(int argc, char *argv[])
{
.
.
.
   createPopupMenu(window);
   gtk_widget_set_events(window, GDK_BUTTON_PRESS_MASK);
   gtk_signal_connect(GTK_OBJECT(window), "button_press_event",
                   GTK_SIGNAL_FUNC(ButtonPressCallback), NULL);
.
.
.
}
-- 
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  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


_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list



--



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