Events in D

Heromyth via Digitalmars-d digitalmars-d at puremagic.com
Tue Aug 29 18:17:09 PDT 2017


On Tuesday, 29 August 2017 at 05:10:25 UTC, bitwise wrote:
> I needed some C# style events, so I rolled my own. Long story 
> short, the result was unsatisfactory.
>

>
> `
> Foo foo;
> foo.onEvent += (int n) => writeln(n);
> foo.onEvent += &baz;
> foo.onEvent -= &baz;
>
> if(foo.onEvent)
>     foo.onEvent(1);
> `
>

I implemented one:


bt_ok = new IupButton("&OK");
         bt_ok.padding = Size(10,2);
bt_ok.click += &bt_ok_click;

private void bt_ok_click(Object sender, CallbackEventArgs e)
{
   string v = textBox.text;
}


See also:
https://github.com/Heromyth/Iup4D/blob/master/Examples/SimpleDemo/main.d
https://github.com/Heromyth/Iup4D/blob/master/Iup4D/toolkit/event.d


More information about the Digitalmars-d mailing list