Enable/Disable a button and mouse clicks
- From: Gabriele Greco <gabriele greco darts it>
- To: gtk-app-devel-list gnome org
- Subject: Enable/Disable a button and mouse clicks
- Date: Wed, 03 Jan 2007 12:09:29 +0100
I've found that if I disable a button after a click on it
(gtk_widget_set_sensitive(button, FALSE)), and then enable it back after
a timed event or something else occurs (...set_sensitive(button, TRUE)
), I'm unable to click on the button with the mouse pointer unless I
exit with the pointer from the button rectangle and enter back in it.
This is a minimal example showing this strange behaviour, I think it's a
wanted behaviour and not a bug (I found this behaviour in GTK 2.6, 2.8,
but not in GTK 2.4), but it's not what I want from my button, there is
any workaround for it?
#include <gtk/gtk.h>
#include <stdio.h>
int do_timeout(GtkWidget *w)
{
printf("Timed out, enabling button\n");
gtk_widget_set_sensitive(w, TRUE);
return 0;
}
int clicked(GtkWidget *w)
{
printf("Button clicked!\n");
gtk_widget_set_sensitive(w, FALSE);
g_timeout_add(2000, do_timeout, w);
}
int main(int argc, char *argv[])
{
gtk_init(&argc, &argv);
GtkWidget *w = gtk_window_new(GTK_WINDOW_TOPLEVEL);
GtkWidget *b = gtk_button_new_with_label("Test");
gtk_container_add(GTK_CONTAINER(w), b);
g_signal_connect(b, "clicked", clicked, NULL);
gtk_widget_show_all(w);
gtk_main();
}
Bye,
Gabry
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]