|
From: | Carpenter, Rob |
Subject: | [XForms] spinner callback repeat delay |
Date: | Thu, 22 Apr 2021 13:24:26 +0000 |
Hi Xforms group, I was looking into using spinners and was having trouble with the repeat delay of the invocation of the callback when one of the buttons is held down. In the included code when using fl_do_forms(), the spinner repeat delay seems to be regulated correctly.
(I attached a zip file with the test code and makefile. The code is listed below, also.) If fl_check_forms() is used in a while loop, the repeat seems not to have a delay and spins as fast as it can.
I know the counter object has code that uses timeouts, but I didn’t see anything similar in the spinner code. Has anybody had any experience with this issue or know how to solve it? I’m using CentOS 7 Thanks, Rob Carpenter #include <stdio.h> #include <stdlib.h> #include "forms.h" enum {ERROR = -1, SUCCESS}; #define LENSTR 256 #define FORM_W 200 #define FORM_H 100 #undef USE_CHECK_FORMS typedef struct { FL_FORM *form; void *vdata; char *cdata; long ldata; FL_OBJECT *done; } FD_form; extern FD_form *create_form_opcon(void); static FD_form *opcon; void done_cb(FL_OBJECT *ob, long data) { printf("i'm done\n"); #ifdef USE_CHECK_FORMS fl_finish(); #endif // USE_CHECK_FORMS exit(0); } void spin_cb(FL_OBJECT *ob, long data) { printf("i'm a spinner %d\n", (int)fl_get_spinner_value(ob)); } FD_form *create_form_opcon(void) { FL_OBJECT *obj; FD_form *fdui = (FD_form *)fl_calloc(1, sizeof(*fdui)); fdui->form = fl_bgn_form(FL_NO_BOX, FORM_W, FORM_H); obj = fl_add_box(FL_UP_BOX, 0, 0, FORM_W, FORM_H, ""); fdui->done = obj = fl_add_button(FL_NORMAL_BUTTON, 10, 10, 50, 30, "Done"); fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast); fl_set_object_callback( obj, done_cb, 0 ); fl_set_button_mouse_buttons(obj, 1); obj = fl_add_spinner( FL_INT_SPINNER, 100, 50, 70, 30, "Spinner" ); fl_set_object_callback( obj, spin_cb, 0 ); fl_end_form(); fdui->form->fdui = fdui; return fdui; } int main(int argc, char *argv[]) { fl_initialize(&argc, argv, "SpinnerTest", 0, 0); opcon = create_form_opcon(); fl_show_form(opcon->form, FL_PLACE_CENTER | FL_FREE_SIZE, FL_FULLBORDER, "Spinner Test"); #ifdef USE_CHECK_FORMS while ((fl_check_forms()) != opcon->done) { } #else // USE_CHECK_FORMS fl_do_forms(); fl_finish(); #endif // USE_CHECK_FORMS return(SUCCESS); } |
spinner.zip
Description: spinner.zip
[Prev in Thread] | Current Thread | [Next in Thread] |