Thanks, sometimes I get stuck in the most elementary (but I'm still learning)
El 16/01/17 a las 13:02, Al Thomas escribió: > ----- Original Message ----- > >> From: "webie...@gmail.com" <webie...@gmail.com> >> Sent: Monday, 16 January 2017, 11:35 >> Subject: [Vala] Stop Gtk.Spinner? >> how can I stop this widget in Genie when I press a key? > > You've not fully understood the concept of scope. > In your constructor, the line: > > var spinner = new Gtk.Spinner() > > creates a new variable, spinner, in the scope of your constructor. > Remove the 'var' keyword and it will work. It will use the spinner > variable declared in the scope of the class and so it will be available > in your 'tecla' class method. > > I've also added the underscore to make the variable private, so it is > only visible in the scope of the class and not to any part of the program > that instantiates the class. > > > // compila con valac --pkg gtk+-3.0 nombre_archivo.gs > [indent=4] > uses Gtk > > init > Gtk.init( ref args ) > var test = new TestVentana() > test.show_all() > Gtk.main() > > class TestVentana:Window > > _spinner: Gtk.Spinner > > construct() > title = "Ejemplo Gtk" > default_height = 300 > default_width = 300 > border_width = 50 > window_position = WindowPosition.CENTER > destroy.connect( Gtk.main_quit ) > > _spinner = new Gtk.Spinner() > _spinner.active = true > add( _spinner ) > > key_press_event.connect( tecla ) > > def tecla( key:Gdk.EventKey ):bool > _spinner.active = false > return true _______________________________________________ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list