[Gtk-sharp-list] Overriding or new handler

Michael Gebhart lists at miketech.net
Fri Mar 10 16:23:14 EST 2006


Ah ok, I see. 

Thanks

Mike
> 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
> appropriate.
> 



More information about the Gtk-sharp-list mailing list