我使用gtk-3.0来创建我的简单UI,我想通过g_signal_emit(…)函数发送一个假事件给GTKEntry。实际上,我不知道应该给这个函数传递什么参数
来源:https://mail.gnome.org/archives/gtkmm-list/2007-June/msg00115.html
void Foo:bar() // handler for signal_clicked()
{
<YOUR TREEVIEW>.grab_focus(); // essential
guint keyval = GDK_Page_Down;
GdkKeymapKey* keys;
gint n_keys;
gdk_keymap_get_entries_for_keyval(gdk_keymap_get_default(),
keyval,
&keys,
&n_keys);
// Note: GdkEvent is an union
GdkEvent* event = gdk_event_new(GDK_KEY_PRESS);
((GdkEventKey*)event)->window =
<YOUR TREEVIEW>get_window()->gobj();
((GdkEventKey*)event)->send_event = TRUE;
((GdkEventKey*)event)->time = GDK_CURRENT_TIME;
((GdkEventKey*)event)->state = GDK_KEY_PRESS_MASK;
((GdkEventKey*)event)->keyval = keyval;
((GdkEventKey*)event)->hardware_keycode = keys[0].keycode;
((GdkEventKey*)event)->group = keys[0].group;
gdk_event_put(event);
// Or, more gdkmm-ish:
// Gdk::Event(event).put();
}