[Gtk-sharp-list] Overriding or new handler

Mike Kestner mkestner at novell.com
Fri Mar 10 13:21:13 EST 2006

On Fri, 2006-03-10 at 18:48 +0100, Michael Gebhart wrote:

> To override the methods:
>     protected override bool OnButtonPressEvent(Gdk.EventButton evnt)

> Or adding a new handler:
>     public MyWidget() 
>      { 
>             ButtonPressEvent += ButtonPressed; 
>      }
> Is there any advantage, or disadvantage?

There is some overhead in signal emission. You are also relinquishing
some control over whether your users see events before your control is
updated.  There are no guarantees that your event handler will run first
even though it is added to the event before any user handlers.  That's
the nature of .Net events.

For those reasons it is probably best to override the VM instead of
connecting to the event.  Don't forget to chain to the base method where

Mike Kestner <mkestner at novell.com>

More information about the Gtk-sharp-list mailing list