Re: XForms: fl_set_input_filter()

Steve Lamont (spl@szechuan.ucsd.edu)
Wed, 25 Mar 98 13:19:01 PST

# To subscribers of the xforms list from spl@szechuan.ucsd.edu (Steve Lamont) :

> I am trying to use an input filter on several input boxes. The filter seems
> to work fine except that I can no longer use tab or return to move between
> input boxes. Actually, tab and return still work but I have to do it twice
> before it moves the focus to the next field. The first time I type tab or
> return, the bell rings for invalid input. The second time, the callback is
> called and focus goes to the next input box.
>
> Here is one of the filters I am using:
> static int myfilter(FL_OBJECT *obj, const char* old, const char* new, int
> c){
> int valid;
> switch(c) {
> case '1' : case '2' : case '3' : case '-' : case 'X': {
> valid = FL_VALID;
> break;
> }
> default : {
> valid = FL_INVALID|FL_RINGBELL;
> }
> }
> return valid;
> }
>
> Any idea of what stupid thing I am not doing :-)

I'm not sure that you are (or are not) doing anything "stupid" -- I
think XForms handles tabs and returns strangely.

For some oddball reason, XForms passes your filter a '\0' as a
character when the tab or return key is pressed the first time (the
second press is not passed to the filter), which your filter takes as
invalid.

Add a case to handle '\0' and you're set:

[...]

case '\0':
valid = FL_VALID;
break;

[...]

spl

_________________________________________________
To unsubscribe, send the message "unsubscribe" to
xforms-request@bob.usuf2.usuhs.mil or see
http://bob.usuf2.usuhs.mil/mailserv/xforms.html
XForms Home Page: http://bragg.phys.uwm.edu/xforms
List Archive: http://bob.usuf2.usuhs.mil/mailserv/list-archives/