[Vala] Connecting delegate to signal



Hello,

I'm playing with Vala now and found this example which does not work:

public class Test : Object {
        public signal void sig (int data);
}

delegate void TestHandler (Test t, int data);

public static void main (string[] args) {

        Test t = new Test();

        TestHandler h = (t, data) => {
                stdout.printf("Data: %d\n", data);
        };

        t.sig (1);
        t.sig += h;
        t.sig (2);
        t.sig -= h;
        t.sig (3);
}

valac complains:
delegate2.vala:20.11-20.11: error: unsupported expression for signal
handler
        t.sig += h;
                 ^
delegate2.vala:22.11-22.11: error: unsupported expression for signal
handler
        t.sig -= h;

Is it bug or this feature is not supposed to be supported? I've found
this example here
http://www.vala-project.org/doc/vala-draft/classes.html#signals




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]