Re: XForms: input objects - newbie question

Martin Doll, Ph.D. (mkhd@into.ch)
Mon, 09 Nov 1998 07:39:34 +0100

# To subscribers of the xforms list from "Martin Doll, Ph.D." <mkhd@into.ch> :

Thank you so much; this was exactly what I needed and worked for the
first shot.
I am share now I can work the right thing out now.

Martin Doll

Steve Lament wrote:
>
> # To subscribers of the xforms list from spl@szechuan.ucsd.edu (Steve Lamont) :
>
> > Would someone kindly give me a startup help showing how I can
> > 'configure' a callback routine that's associated with a normal input obj
> > FL_NORMAL_INPUT to:
> >
> > simply to *get* the line (in a variable let's say "line_input" so I can
> > retrieve it later by "main")
> > and then *print* it to the screen using "printf("That's it: %c.\n", line_input);".
>
> The easiest way to assign a callback is to use the Forms Designer
> (`fdesign'). Just type the name of the callback in the appropriate
> box in the Attribs dialog, close it with the Accept button, and save
> the form.
>
> If for some reason you want to assign the callback on your own, use
> the function fl_set_object_callback():
>
> fl_set_object_callback(obj,input_cb,0);
>
> The callback itself is quite straightforward. To get the input from
> an object, use the fl_get_input() function call:
>
> void input_cb(FL_OBJECT *ob, long data)
> {
>
> const char *line_input = fl_get_input( ob );
>
> printf( "That's it: %s.\n", line_input );
>
> }
>
> [note that fl_get_input() returns a pointer to const char, not a char,
> so your printf() would probably produces something strange]
>
> If you want the string produced by the Input object to be seen by
> other objects or your main, simply make `line_input' a global:
>
> const char *line_input;
>
> void input_cb(FL_OBJECT *ob, long data)
> {
>
> line_input = fl_get_input( ob );
>
> }
>
> Globals, of course, are frowned upon by the more pedantic amongst us.
>
> You might want to look at some of the demos which come along with the
> XForms distribution for other examples.
>
> 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/

_________________________________________________
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/