Problem with scale widget's slider



Good day

I've encountered a bug while using
"enter_notify_event" & "leave_notify_event" with scale
widget. What I'm trying to do is that whenever mouse's
cursor enters into the scale widget, this event should
be detected using "enter_notify_event" and a message
should be displayed in a statusbar widget. Similarly
when cursor moves out from the scale then
"leave_notify_event" detects it and the message is
removed (popped out).

The Problem:
============
When the cursor is moved a bit fast in and out for
some time over the "slider" of the scale widget then
the message is not popped out properly. Kindly tell me
its cure if you know.

Some observations regarding the problem:
========================================
1. This problem only occurs if you move cursor over
the slider. Otherwise you may move cursor over the
trough as fast as you can and the program works fine.

2. Secondly this is the problem with range widgets
only. It works perfectly fine with button widgets.

Source code: (modification of "statusbar.c" example of
the tutorial)
============
//Kindly run it, move the cursor fast over the slider
and see the result.

#include <gtk/gtk.h>

GtkWidget *status_bar;

//Call back for enter event
gint push_item( GtkWidget *widget,GdkEventAny *event,
gpointer data)
 {
 char buff[50];

 g_snprintf(buff, 50, "You've entered into scale");
 
 gtk_statusbar_push(GTK_STATUSBAR(status_bar),
GPOINTER_TO_INT(data), buff);

 return(TRUE);
 }

// Call back for leave event
gint remove_item( GtkWidget *widget,GdkEventAny
*event, gpointer data)
 {
 gtk_statusbar_pop( GTK_STATUSBAR(status_bar),
GPOINTER_TO_INT(data));

 return (TRUE);
 }

int  main( int argc, char *argv[])
 {
 GtkWidget *window;
 GtkWidget *table;
 GtkWidget *scale;
 guint context_id;
                       
 gtk_init (&argc, &argv);
                       
 window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

gtk_signal_connect(GTK_OBJECT(window),"destroy",GTK_SIGNAL_FUNC(gtk_exit),
NULL);

 table = gtk_table_new (2,1,TRUE);
 gtk_container_add (GTK_CONTAINER (window), table);

 scale = gtk_hscale_new(NULL);
 gtk_table_attach_defaults (GTK_TABLE(table), scale,
0, 1, 0, 1);
 gtk_widget_show (scale);

 status_bar = gtk_statusbar_new();
 gtk_table_attach_defaults (GTK_TABLE(table),
status_bar, 0, 1, 1, 2);
 gtk_widget_show (status_bar);

 context_id =
gtk_statusbar_get_context_id(GTK_STATUSBAR(status_bar),
"Statusbar test");


gtk_signal_connect(GTK_OBJECT(scale),"enter_notify_event",
GTK_SIGNAL_FUNC(push_item),
GINT_TO_POINTER(context_id));

gtk_signal_connect(GTK_OBJECT(scale),
"leave_notify_event", GTK_SIGNAL_FUNC(remove_item),
GINT_TO_POINTER(context_id));

gtk_widget_show (table);

gtk_widget_show (window);                       

gtk_main ();
                       
return(0);
}

__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - Buy the things you want at great prices.
http://auctions.yahoo.com/




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]