[Top][All Lists]

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

Re: forms: set_field_type, submit button

From: Thomas Dickey
Subject: Re: forms: set_field_type, submit button
Date: Tue, 26 Apr 2005 17:01:06 -0400 (EDT)

On Tue, 26 Apr 2005, Moritz Beller wrote:


providing the user with a form to enter integers, it sometimes happens
that you want to allow a specific open-end range to be input, i.e. from
49151 to infinity, as you may wish when asking for a port number (as we
don't want to mess up the registered ports, neither the well known
ones). Regularly, you'd expect an expression such as
set_field_type(field, TYPE_INTEGER, 0, 1024); to work, but in this case,
since we exceed the range of signed integer anyway, ncurses' current
set_fiel_type isn't much of a help.

As I understand your question - you could define your own field type
and make up whatever rules you needed.  (That reply sounds familiar -
I think the topic came up on this list about a year ago). The form/fty_XXX.c files in ncurses source implement the different types,
and aren't that hard to follow.

My second question is regarding a form, the user has just filled out.
I'd like to have an OK button beyond the fields so that the user has to
actually leave the last field in order to proceed, which sets the
field's buffer to the correct value. How'd you achieve such a button?
Feel free to mail your own ideas, if you disagree with the OP's submit
button suggestion.

I think you could do it by making your program keep track of the keystrokes (it has to anyway), and when doing a next-field from the last field of the form, translate that into an application code that your program can use to switch to the Ok/Cancel buttons. I don't recall any example within ncurses that does that sort of traversal, but dialog does it (I've made the logic for the bottom row of buttons reusable for the different widgets).

Thomas E. Dickey

reply via email to

[Prev in Thread] Current Thread [Next in Thread]