Re: Button events not working
- From: "ldx" <ldxlq 263 net>
- To: "Esteban Quijano Vincenzi" <Esteban Quijano artinsoft com>
- Cc: "gtk" <gtk-list gnome org>
- Subject: Re: Button events not working
- Date: Tue, 10 Jul 2001 08:29:15 +0800
Button events not workingHi,
I am new hand of GTK programming. But I think maybe you should connect those events to a button not a window.
ldx
----- Original Message -----
From: Esteban Quijano Vincenzi
To: gtk-list gnome org
Sent: Tuesday, July 10, 2001 5:36 AM
Subject: Button events not working
Given following code:
#include <gtk/gtk.h>
gboolean
button_press_event(GtkWidget *widget, GdkEventButton *event, gpointer data)
{
g_print("button-press-event\n");
return FALSE;
}
gboolean
button_release_event(GtkWidget *widget, GdkEventButton *event, gpointer data)
{
g_print("button-release-event\n");
return FALSE;
}
gboolean
key_press_event(GtkWidget *widget, GdkEventKey *event, gpointer data)
{
g_print("key-press-event\n");
return FALSE;
}
gboolean
key_release_event(GtkWidget *widget, GdkEventKey *event, gpointer data)
{
g_print("key-release-event\n");
return FALSE;
}
gboolean
delete_event(GtkWidget *widget, GdkEvent *event, gpointer data)
{
gtk_widget_destroy(widget);
gtk_main_quit();
return FALSE;
}
int main(int argc, char* argv[])
{
GtkWidget *window;
gtk_set_locale ();
gtk_init (&argc, &argv);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_signal_connect(GTK_OBJECT(window), "delete-event", GTK_SIGNAL_FUNC(delete_event), NULL);
gtk_signal_connect(GTK_OBJECT(window), "button-press-event", GTK_SIGNAL_FUNC(button_press_event), NULL);
gtk_signal_connect(GTK_OBJECT(window), "button-release-event", GTK_SIGNAL_FUNC(button_release_event), NULL);
gtk_signal_connect(GTK_OBJECT(window), "key-press-event", GTK_SIGNAL_FUNC(key_press_event), NULL);
gtk_signal_connect(GTK_OBJECT(window), "key-release-event", GTK_SIGNAL_FUNC(key_release_event), NULL);
gtk_widget_show(window);
gtk_main ();
return 0;
}
I tested this program under RH Linux 7.0 and under Windows 2000 with the gtk port to win32 and it behaves exactly the same.
- Both button-press-event and button-release-event are not responding at all when clicking over the window.
- key-release-event is not responding either.
- When I press a key without releasing it, the window starts calling key_press_event(...) many, many times.
I supposed that the key-press-event would be emitted only once when I press a key so, when I release it the key-release-event is emitted.
Is there a problem connecting these events with toplevel windows?
Is this the correct behavior?
Thanks,
Esteban Quijano Vincenzi
Artinsoft corp.
Quality Assurance
Intel Project
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]