Re: Constrained text entry
- From: Tony Gale <gale gtk org>
- To: Jeff Henrikson <jehenrik yahoo com>
- Cc: gtk-list gnome org
- Subject: Re: Constrained text entry
- Date: 16 Aug 2001 16:55:22 +0100
On 09 Aug 2001 00:02:24 -0400, Jeff Henrikson wrote:
> Hi, a couple of months ago I was developing a prototype app in GTK and encountered the problem below. At the time I painstakingly
> searched the list archive for an answer. I remember one month had 4 separate top level threads which basically boiled down to how
> to do one general thing, and none were answered. At that point I just laughed and decided that the prototype code didn't have to
> be perfect. But now I am thinking about doing a production quality GTK app, and I need to know if this is possible.
>
> The problem is very simple and common: I want to have a constrained GtkEntry widget, suppose one which only holds a floating point
> double. So obviously you just catch the signal that lets the value change, and if it parses in your favorite ascii->number
> function, you are all set. If it doesn't, you need to set the entry box back to what it was before so the user can see that it
> didn't work.
>
> Problem: GtkEntry provides apparently only two signals for changing. "changed" catches every change. I insert an "a" into the
> number and I immediately get called. That's not the right behavior because you can't always enforce the structure correctly that
> way. Perhaps you wonder, "But if you want a number in the box, why would you allow a letter to be entered?" One counterexample is
> that a floating point number in string form can standardly contain the character "e", yet simply allowing only numbers and "e" in
> the text still allows plenty of awful junk. "1eee7ee7e" for example. Likewise "-" and "." characters.
>
> The other signal provided is "activate" which gets called if the user puts in text and hits enter. But in that case, the user
> needs to hit enter to see that what he did is invalid. He could presumably go on using his app for 5 minutes not realizing that he
> put 2 decimal points in his number, still displayed on screen but not refleted by the program running.
<large snipage>
Did you read the FAQ entry on doing this?
I removed the three scenarios you described as they are confusing, and
don't actually tell us what you are trying to do or what the problem is
in your specfic case.
Read the FAQ, and then if that doesn't solve the problem you are
actually have, please come back and ask again with more details of the
problem you actually have, not some hypothetical ones you just thought
up.
-tony
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]