Re: How to enter a floating-point number ?

On Sat, May 29, 2004 at 05:21:50PM +0200, David Necas (Yeti) wrote:
On Sun, May 30, 2004 at 12:54:20AM +1000, Russell Shaw wrote:

The parsers i've done go forwards and backwards, so you can
use the backspace key. If you change a character midway in the
number, the parser just rescans the entire string (as it does
for all keypresses) and allows or disallows that change,
because it remembers the previous entry.

I understand this; it's what I tried and found annoying.
It doesn't allow to move decimal point by adding a new one
first and removing the old one later, the same for signs of
the whole number and of its exponent, deletion of exponent
char by char starting with the `e', and probably other
things that have non-numbers as their intermediate steps.

If you just type numbers it can be OK, but if you want to
fiddle with them you have to think about the Approved
Editing Procedure instead of just doing anything feasible
that changes the current number to the one you want there --
or else the thing starts beeping on you like mad.

The Right Way of handling this type of entry is to have a realtime
visual validity indicator on the control so the user always knows
whether or not the entry is valid.
The state of this indicator must change as they enter text.
Only if the user attempts to commit to an invalid entry do you alert
them with a dialog. This way, the transient state of the entry can
be invalid and yet the operator will know when it becomes valid
without any risk of punishment (an obnoxious dialog they have to

The visual indication can be accomplished by background color, or
some kind of highlighting with a shape (like a "focus" ring,
or a bullet off to the side).
The latter is probably better for general purpose GTK use. We use
the color in special factory automation applications but you have
to be careful tinkering with colors for general purpose desktop apps.

Good luck,

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