Re: [Vala] can't receive scroll event in object's method




-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Thanks, finally it works!

El 28/09/11 09:38, Iñigo Serna escribió:
Hello,

On 27 September 2011 21:13, rastersoft <raster rastersoft com> wrote:
I'm trying to receive the scroll event in an object, but I'm unable to
do it. If I do:

[...]
this.mybox = new EventBox();
mybox.add_events (Gdk.EventMask.SCROLL_MASK);
mybox.scroll_event.connect(do_scroll);
[...]

public static bool do_scroll(Gtk.Widget w,Gdk.EventScroll event) {

GLib.stdout.printf("Scroll\n");
return true;
}

it works, but since "do_scroll" is static, it has no access to the
original object. But if I try to use a method in the object, to be
able to use "this.", like in:

[...]
this.mybox = new EventBox();
mybox.add_events (Gdk.EventMask.SCROLL_MASK);
mybox.scroll_event.connect(do_scroll);
[...]

public bool do_scroll(Gtk.Widget w,Gdk.EventScroll event) {

GLib.stdout.printf("Scroll\n");
this.call_to_an_objects_method();
return true;
}

it never receives the scroll event.

I also tried to add [CCode(instance_pos=-1)] before the method, but it
doesn't work :(

What must I do to make it work?

Thanks.

- --
Nos leemos
RASTER (Linux user #228804)
raster rastersoft com http://www.rastersoft.com


try something like:

[...]
mybox = new EventBox();
mybox.add_events (Gdk.EventMask.SCROLL_MASK);
mybox.scroll_event.connect( () => {
GLib.stdout.printf("Scroll\n");
this.call_to_an_objects_method();
return true;
});
[...]


Hope it helps,
Iñigo Serna
_______________________________________________
vala-list mailing list
vala-list gnome org
http://mail.gnome.org/mailman/listinfo/vala-list

- -- 
Nos leemos
                 RASTER    (Linux user #228804)
raster rastersoft com              http://www.rastersoft.com

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk6DkxQACgkQXEZvyfy1ha+E+ACgmpNXYmTiAtZdh25zuGZV7CgG
mDwAoKx3Ug2f0EiwvbIN7cPv3RATJVqj
=gbyX
-----END PGP SIGNATURE-----




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