[Gtk-sharp-list] custom widget

Michael Gebhart lists at miketech.net
Wed Mar 8 06:33:30 EST 2006


Hi,

I wanted to write a custom gtk# widget, which should react on button
pressed events. 

This is my widget: 

 public class PaintWidget : Gtk.Widget 
{ 
                                      
     public PaintWidget() 
     { 
            ButtonPressEvent += ButtonPressed; 
     } 
                                       
     public void ButtonPressed(object o, EventArgs args) 
     { 
           Console.WriteLine("Test"); 
     } 
} 
                                    



And this is my MainWindow: 


public class MainWindow: Gtk.Window 
{    
     public MainWindow (): base ("") 
     { 
          this.Add(new PaintWidget()); 
          this.ShowAll(); 
     } 
} 
                                    



When I run this program I get this: 

(<unknown>:18300): Gtk-CRITICAL **: gtk_widget_real_realize: assertion
`GTK_WIDGET_NO_WINDOW (widget)' failed 

(<unknown>:18300): Gtk-CRITICAL **: gtk_widget_real_map: assertion
`GTK_WIDGET_REALIZED (widget) == TRUE' failed 

The window is shown, but my events aren't called. Any ideas, what I did
wrong? 

Greetings 

Mike



More information about the Gtk-sharp-list mailing list