I use an GtkEntry to input numbers. I try to make it won't accept otherTry this:
keys except number keys, which means when the user pushes the other
keys, it won't shows up.I use the signal call back function. What I am doing now is:
1. set signal call back function (signal: key_release_event)
if the input key is not a number key, then delete it.But the thing is that the wrong key still will show up for a very short
time. I know this is because I use the key_release_event signal.So I try to put such function in the key_pressed_event.
The thing is : In the "key_pressed_event" call back function, if I
detect the wrong key, how I can prevent it from showing in the entry on
the screen?If someone knows, please teach me ASAP
Thanks
--
To unsubscribe: mail -s unsubscribe gtk-list-request@redhat.com < /dev/null
gtk_signal_connect (GTK_OBJECT (entry1),
"key_press_event",
GTK_SIGNAL_FUNC (on_entry1_key_press_event),
NULL);
...
gboolean on_entry1_key_press_event(GtkWidget
*wid, GdkEventKey *ev, gpointer data) {
gint key = ev->keyval;
if(key < '0' || key > '9') {
fprintf(stderr, "No Numeric\n");
gtk_signal_emit_stop_by_name(GTK_OBJECT(wid),
"key_press_event");
return(TRUE);
}
return(FALSE);
}
(I don't know if return values are used later
...)
Good luck.