[449] in The GTK GIMP ToolKit mailing list archive

home help back first fref pref prev next nref lref last post

[gtk-list] Re: labels and events

daemon@ATHENA.MIT.EDU (owt1@cornell.edu)
Fri Jul 11 12:31:08 1997

From: owt1@cornell.edu
Date: Fri, 11 Jul 1997 12:30:55 -0400 (EDT)
To: gtk-list@redhat.com
In-Reply-To: <199707111523.RAA17299@pcjeroen.ubu.ruu.nl>
Resent-From: gtk-list@redhat.com
Reply-To: gtk-list@redhat.com



On Fri, 11 Jul 1997, Hoek wrote:

> Current window is X
> 
> So, can I use a label for X and connect that to an event handler, so that
> when I click on X a menu will pop up?  So far I haven't been able to
> make a label respond to anything.  Or is it possible to create a menu_bar
> without a border of any kind?

It isn't possible to connect a event handler to a label, since labels
don't have associated X windows. So you'll need to stick your label
inside another widget, and connect to button press events on that 
widget. One possibility, if I remember corrrectly, is the Viewport
widget. (Boxes, the obvious choice, also don't have windows.) 

Then do something like

gtk_widget_set_events(mywidget,GDK_BUTTON_PRESS_MASK);
gtk_signal_connect(GTK_OBJECT(mywidget,"button_press_event",
		   button_press_callback, NULL);

where

static gint
button_press_callback(GtkWidget mywidget, GdkEventButton *event)
{
  gtk_menu_popup(GTK_MENU(mymenu),NULL,NULL,NULL,NULL,
		 event->button);
}

(This is ofcourse, untested)

Regards,
                                        Owen

--
To unsubscribe: mail -s unsubscribe gtk-list-request@redhat.com < /dev/null


home help back first fref pref prev next nref lref last post