[Gtk-sharp-list] (no subject)

Jeremiah McElroy Jeremiah McElroy <jeremiah.mcelroy@gmail.com>
Tue, 21 Dec 2004 11:05:07 -0500


If I understand correctly, you would like to create an image that acts
like a button, but does not have the borders that a button has.

If you take a look at the documentation for Gtk.Image, you'll find
that you can include the Image inside a Gtk.EventBox to hook it up to
events.

Here's an example.  Keep in mind that this example is incomplete and
you would still have to provide a one or two more methods and hook up
some additional events, depending on what you wanted.

public static void Main (string [] args) 
{
	Gtk.Window window;
	EventBox eventbox;
	Gtk.Image image;
	
	Application.Init ();
	
	window = new Gtk.Window ("Eventbox");
	window.DeleteEvent += new DeleteEventHandler (delete_event);

	window.BorderWidth = 10;

	eventbox = new EventBox ();
	window.Add (eventbox);
	eventbox.Show();
	
	image = new Gtk.Image ("myImage.png");
	
	eventbox.Add (image);
	image.Show ();

	eventbox.ButtonPressEvent += new ButtonPressEventHandler (exitbutton_event);

	eventbox.Realize();

	window.Show();
		
	Application.Run();
}

static void exitbutton_event (object obj, ButtonPressEventArgs args)
{
	Application.Quit();
}



On Tue, 21 Dec 2004 12:17:41 +1100, roy <roy@websitemanagers.com.au> wrote:
>  
> I am a new beginner , I hope I can use image, but I want to use the clicked
> event. can you help me . and I also want to change the button's style as I
> do want let them looks like label. so I can use the clicked event. 
>