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



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



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