我试图在右键单击Clutter Actor时显示gtk菜单弹出窗口。由于某种原因,菜单没有显示。这是我的代码(不是全部,只有处理程序)
button_press_event.connect((event) => {
if (event.click_count < 2 && event.button == 1) {
debug("Icon simple click\n");
} else if (event.click_count < 2 && event.button == 3) {
debug("Showing Pop Up menu\n");
var popup_menu = new PopupMenu();
popup_menu.add_menu_item("Prueba 1");
popup_menu.show_all();
popup_menu.show_popup();
return true;
}
return false;
});
PopupMenu是我做过的gtk.menu的litle包装
public class PopupMenu : Gtk.Menu {
public PopupMenu.from_gtk_widget (Gtk.Widget parent) {
parent.button_release_event.connect((event) => {
if(event.button == 3) this.show_popup();
return true;
});
}
construct {
}
public Gtk.MenuItem add_menu_item (string label) {
var item = new Gtk.MenuItem.with_label(label);
this.append (item);
return item;
}
//Draw the popup at the mouse position
public void show_popup() {
debug("Popup Showing\n");
this.popup(null, null, null, 2, 0);
}
}
演员在一个有flowlayout的演员里面。这个actor在一个透明的gtk窗口里面。显示调试消息。
为什么这不起作用?感谢