|
发表于 2005-1-4 14:07:48
|
显示全部楼层
[code:1]
//interface.c
g_signal_connect ((gpointer) entry1, "key_release_event",
G_CALLBACK (on_entry1_key_release_event),
entry3);
g_signal_connect ((gpointer) entry2, "key_release_event",
G_CALLBACK (on_entry2_key_release_event),
entry3);
//callback.c
gboolean
on_entry1_key_release_event (GtkWidget *widget,
GdkEventKey *event,
gpointer user_data)
{
GtkWidget *entry3=(GtkWidget *)user_data;
gtk_entry_set_text(GTK_ENTRY(entry3),gtk_entry_get_text(GTK_ENTRY(widget)));
return FALSE;
}
gboolean
on_entry2_key_release_event (GtkWidget *widget,
GdkEventKey *event,
gpointer user_data)
{
GtkWidget *entry3=(GtkWidget *)user_data;
gtk_entry_set_text(GTK_ENTRY(entry3),gtk_entry_get_text(GTK_ENTRY(widget)));
return FALSE;
}
[/code:1]
entry1,entry2,entry3是三个文本输入框,gtk没有直接的enter时间,只有键盘的按下,释放时间,我用的是按键释放事件,但我们在回调函数里可以做一个判断,只有是释放的键是回车时才去做我们的事情,这个判断可以利用那个GdkEventKey *event来完成。我贴的代码没做这些判断,你自己试试吧。 |
|