I've run into something that has me scratching my head. The following code, based on a number of similar examples, doesn't work. I'm starting to think I can only hook an event to a button if it's subclassed.
Can anyone set me straight?
import gtk.MainWindow;
import gtk.Main;
import gtk.Button;
import gtk.Widget;
import gdk.Event;
void main(string[] args)
{
Main.init(args);
MainWindow myAppWin = new MainWindow("Test Rig");
Button myButt = new Button();
myButt.setLabel("My Butt");
myButt.addOnButtonRelease(&quitApp);
myAppWin.add(myButt);
myAppWin.addOnDestroy(delegate void(Widget w) { quitApp(); });
myAppWin.showAll();
Main.run();
} // main()
void quitApp(Event event, Widget widget)
{
writeln("Quit, eh");
Main.quit();
return(true);
} // quitApp()