[Gtk-sharp-list] Click?

Joe Shaw joeshaw@novell.com
Thu, 12 Aug 2004 11:35:11 -0400


On Wed, 2004-08-11 at 21:31 -0500, Zak wrote:
> First off, I'm a complete GTK# newbie but have quite a bit of C#, SWF,
> and ASP.NET experience.
> 
> I have an HBox with several other controls packed inside and now I
> want to receive mouse click events that occur anywhere within the
> HBox.  What is the best way to do this?  I've tried a few things
> (deriving my own control from HBox and creating a Click event with
> SignalAttribute("clicked") and using the ButtonPressEvent, for
> instance) with no success thus far.

Deriving the class shouldn't be necessary.  You probably need to add the
ButtonPressEvent mask to the accepted events of the HBox.  You can do
this by doing something like:

mybox.Events |= Gdk.EventMask.ButtonPressMask;

And then you can attach to the ButtonPressEvent.

(Although you might actually want to use ButtonReleaseMask and
ButtonReleaseEvent, since most of the time events rarely happen on
button presses but button releases.)

I don't remember 100%, but it's possible that the HBox class is a "no
window" widget, which means that it wouldn't get any of its own events
at all.  If this is the case, just pack it into an EventBox and then do
the above on the EventBox.  But you probably don't need to do this.

Joe