Next: ValSliders, Previous: Buttons, Up: Part I Defining Forms [Contents][Index]
Sliders are useful in letting the user indicate a value between some fixed bounds. A slider is added to a form using the routine
FL_OBJECT *fl_add_slider(int type, FL_Coord x, FL_Coord y, FL_Coord w, FL_Coord h, const char *label);
The two most important types of sliders are FL_VERT_SLIDERM
and
FL_HOR_SLIDER
. The former displays a slider that can be moved
vertically and the latter gives a slider that moves horizontally. In
both cases the label is placed below the slider. Default value of the
slider is 0.5 and can vary between 0.0 and 1.0. These values can be
changed using the routines:
void fl_set_slider_value(FL_OBJECT *obj, double val); void fl_set_slider_bounds(FL_OBJECT *obj, double min, double max);
Whenever the value of the slider is changed by the user, it results in the slider being returned to the application program or the callback routine invoked. The program can read the slider value using the call
double fl_get_slider_value(FL_OBJECT *obj);
and take action accordingly. See the example program demo05.c for the use of these routines.