RE: [gtk-list] entry input verification [Was: Uppercase only ent
- From: Trog <trog gtk org>
- To: Ralf Corsepius <corsepiu faw uni-ulm de>, gtk-list redhat com
- Cc: trog gtk org
- Subject: RE: [gtk-list] entry input verification [Was: Uppercase only ent
- Date: Tue, 29 Feb 2000 16:17:56 -0000 (GMT)
On 29-Feb-2000 Ralf Corsepius wrote:
> On a related subject (It might be an FAQ, but ...):
[NOTE to self] write a FAQ entry for this.
>
> I am looking for a method to provide input verification on
> GtkEntry/GtkEditable, e.g. I am looking for an GtkEditable which
> shall only
> accept a subset of characters (eg. those that match a regular
> expression, or
> integers only) as text input.
>
> [Actually, I looking for something similar to Motif's
> XmNmodifyVerifyCallback
> for XmTextFieldWidgets]
>
> The approach you outline above doesn't seem to work in my case,
> because the
> insert_text signal does't seem to allow changing the size of the
> inserted
> text.
> Implementing it with the changed signal seems to be possible, but
> seems to be
> rather ineffective and also seems to suffer from the "infinite
> loop" issue
> (changed being called because invoking "set_text" ).
Attach to the "key_press_event" event of the entry widget:
gtk_signal_connect(GTK_OBJECT(entry),
"key_press_event"
GTK_SIGNAL_FUNC(entry_key_press),
data);
Then the callback function goes along the lines:
gint entry_key_press (GtkWidget *widget,
GdkEventKey *event,
gpointer data)
{
switch (event->keyval) {
case GDK_F1:
gtk_signal_emit_stop_by_name(GTK_OBJECT(widget),"key_press_event");
gtk_editable_insert_text( GTK_EDITABLE(widget), "hello",
5,>K_EDITABLE(widget)->current_pos);
return TRUE;
case GDK_F2:
gtk_signal_emit_stop_by_name(GTK_OBJECT(widget),"key_press_event");
gtk_editable_insert_text( GTK_EDITABLE(widget), "world",
5,>K_EDITABLE(widget)->current_pos);
return TRUE;
}
return FALSE;
}
I think that covers what you need. Well, you should get the idea
anyway.
-tony
---
E-Mail: trog@gtk.org
If Beethoven's Seventh Symphony is not by some means abridged, it will soon
fall into disuse.
-- Philip Hale, Boston music critic, 1837
Go Bezerk! http://www.gtk.org/~trog
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]