Re: Why function does not work with delegate

2019-05-23 Thread Alex via Digitalmars-d-learn
On Wednesday, 22 May 2019 at 23:54:47 UTC, Adam D. Ruppe wrote: On Wednesday, 22 May 2019 at 22:33:52 UTC, Alex wrote: auto x = (GdkEventButton* e, Widget w) ... X.addOnButtonPress(x); Why is x not a delegate? Because you didn't ask for one and it didn't have to be. Just add the dele

Re: Why function does not work with delegate

2019-05-22 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 22 May 2019 at 22:33:52 UTC, Alex wrote: auto x = (GdkEventButton* e, Widget w) ... X.addOnButtonPress(x); Why is x not a delegate? Because you didn't ask for one and it didn't have to be. Just add the delegate keyword to ask for one: auto x = delegate(GdkEventButton* e

Re: Why function does not work with delegate

2019-05-22 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, May 22, 2019 at 10:33:52PM +, Alex via Digitalmars-d-learn wrote: > In gtkD one can use a lambda directly: > > X.addOnButtonPress((GdkEventButton* e, Widget w) ... > > but if I try move the lambda in to a variable so I can use it with > multiple handlers, I get an error: > >

Why function does not work with delegate

2019-05-22 Thread Alex via Digitalmars-d-learn
In gtkD one can use a lambda directly: X.addOnButtonPress((GdkEventButton* e, Widget w) ... but if I try move the lambda in to a variable so I can use it with multiple handlers, I get an error: // x is a function and does not work auto x = (GdkEventButton* e, Widget w) ... X.a