Re: XForms: problem with the input box

Steve Lamont (spl@szechuan.ucsd.edu)
Mon, 7 Sep 98 08:51:21 PDT

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

> i am a new user to xforms. i have been facing a problem with the input
> text box. if the length of text input is greater than the length of the
> box the text scrolls to the left all right. but there is a problem if we
> want to access the text that has scrolled beyond the left of the box.
> i.e when we move the cursor towards the left the cursor just disappears
> beyond the left boundary of the text box. ...

This is a known bug, I believe.

Here is a hack I developed to work around the problem. The code
should be self-explanatory.

Create a posthandler for your input object(s) as follows:

int input_posthandler( FL_OBJECT *obj, int event, FL_Coord mx, FL_Coord my,
int key, void *xevent )

{

const char *current_text = fl_get_input( obj );
int l_current_text = strlen( current_text );
int textwidth = fl_get_string_width( obj->lstyle, obj->lsize,
current_text, l_current_text );

if ( textwidth > obj->w ) {

int xpos;
int ypos;
int xoffset;

fl_get_input_cursorpos( obj, &xpos, &ypos );

xoffset = fl_get_string_width( obj->lstyle, obj->lsize,
current_text, xpos );
if ( xoffset < fl_get_input_xoffset( obj ) )
fl_set_input_xoffset( obj, xoffset );

}
return !FL_PREEMPT;

}

If you have more than one Input object, you need only create one
posthandler, since it carries no internal state and it should be
usable by multiple objects simulataneously.

Register it in the standard manner for all the inputs in your form:

[...]

fd_try = create_form_try();

fl_set_object_posthandler( fd_try->input1, input_posthandler );
fl_set_object_posthandler( fd_try->input2, input_posthandler );
fl_set_object_posthandler( fd_try->input3, input_posthandler );

fl_show_form(fd_try->try,FL_PLACE_CENTERFREE,FL_FULLBORDER,"try");

[...]

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/