Further to investigating signals, callbacks, and delegates, I've been trying to find a way way to pass arguments to a callback attached to addOnButtonRelease() and its ilk the way I can with addOnClicked() in the example below.

The big stumbling block seems to be that addOnButtonRelease(), addOnButtonPress(), etc. — any of the Widget object functions, in fact — return a bool whereas addOnClicked() is void.

I've tried a number of approaches, but I'm not coming up with anything that works. In the example below, I've used addOnClicked() in two ways (including the one that's commented out) and they both work, but using similar syntax with addOnButtonRelease() or any of the others just spits out errors.

Is this possible in a simple-ish way without having to, metaphorically speaking, balance the widget on its elbow?

import std.stdio;
import gtk.MainWindow;
import gtk.Main;
import gtk.Widget;
import gtk.Button;
import gdk.Event;

void main(string[] args)
{
	string title = "Test Rig OOP";
	Main.init(args);
	TestRigWindow myTestRig = new TestRigWindow(title);
	
	MyButton button = new MyButton("Click this", args);
	myTestRig.add(button);
	
	myTestRig.showAll();
	Main.run();
	
} // main()


class TestRigWindow : MainWindow
{
	this(string title)
	{
		super(title);
		addOnDestroy(&quitApp);
		
	} // this()
	
	
	void quitApp(Widget w)
	{
		writeln("Bye.");
		Main.quit();
		
	} // quitApp()

} // class TestRigWindow

 
class MyButton : Button
{
	this(string label, string[] args)
	{
		super(label);
		//addOnClicked(delegate void(Button b) { buttonAction(message); });
		addOnClicked(delegate void(_) { buttonAction(args); });
		
	} // this()
	
	
	void buttonAction(string[] args)
	{
		foreach(message; args)
		{
			writeln("The message is: ", message);
		}
		
	} // buttonAction()
	
} // class MyButton