Re: [Vala] Can not connect Gtk.Action to a function



 var actiongroup = new Gtk.ActionGroup("MainActions");

 Gtk.MenuItem menuitem = new Gtk.MenuItem.with_mnemonic("_Actions");
 Gtk.Menu actionmenu = new Gtk.Menu();
 Gtk.Action test = new Gtk.Action ("Test", "Test", null, null);
 actiongroup.add_action (test);
 test.activate.connect ((source) => {
      sample_func();
 });

 Gtk.MenuItem testitem = (Gtk.MenuItem) factoraction.create_menu_item();
 actionmenu.append(testitem);
 menuitem.set_submenu(actionmenu);
 menubar.append (menuitem);

 ....

 public void sample_func()
 {
     debug ("sample function executed");
 }

Could this be the elusive bug?
Gtk.MenuItem testitem = (Gtk.MenuItem) factoraction.create_menu_item();

i.e. you visual doesn't correspond to your internal.

hand
Nor Jaidi Tuah





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