Sign up

DrawingArea.addOnDraw()

In lots of places I have code like:

alignTool = new DrawingArea(57, 12);
alignTool.addOnDraw(&onDraw);

This was fine in 2.4, but now gets flagged as deprecated. I should be using:

void addOnDraw(bool delegate(Scoped!Context, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)

Where is the 'Scoped' template described. I see scoped in std.typecons.

How do I change my code to get rid of the deprecation?

Re: DrawingArea.addOnDraw()

On 04/20/2015 02:32 PM, Steve Teale wrote:

In lots of places I have code like:

alignTool = new DrawingArea(57, 12);
alignTool.addOnDraw(&onDraw);

This was fine in 2.4, but now gets flagged as deprecated. I should be using:

void addOnDraw(bool delegate(Scoped!Context, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)

Where is the 'Scoped' template described. I see scoped in std.typecons.

How do I change my code to get rid of the deprecation?

Change the signature of onDraw to:

bool onDraw(Scoped!Context cr, Widget w)

With newer versions of dmd this is indeed the one from std.typecons.
GtkD provides the "Scoped" alias so you are able to use it in the
function signature.