On 08.10.2011 08:45, Richard Sanders wrote:
> I am not getting any success getting a callback.
>
> Looking at Fl_Spinner.H and sb_cb in particular, I see the last
> statement is "sb->do_callback();" where sb is Fl_Group widget for the
> spinner. I have tried (I think) every combination for when() and I
> seem to be getting a rigid digit for my efforts.
>
> Am I barking mad or barking up the wrong tree?
Usually we would ask you for some simple example code that shows
what you've done so far... However, I did a small example myself, and
it works well for me - w/o setting any when() condition, i.e. using
defaults. Please see appended example code, and if you have further
questions, please ask again.
Albrecht
--- snip ---
// file: spinner.cxx
// use: "fltk-config --compile spinner.cxx" to compile
#include <FL/Fl_Window.H>
#include <FL/Fl_Spinner.H>
#include <FL/Fl_Box.H>
#include <FL/Fl.H>
#include <stdio.h>
void spinner_cb(Fl_Widget *w, void *v) {
Fl_Spinner *s = (Fl_Spinner *)w;
Fl_Box *message = (Fl_Box *)v;
int val = (int)s->value();
static char buf[100];
sprintf(buf,"received callback: value = %d",val);
message->label(buf);
message->redraw();
printf("%s\n",buf); fflush(stdout);
}
int main (int argc, char **argv) {
Fl_Window *win1 = new Fl_Window(250,150);
Fl_Spinner *spinner = new Fl_Spinner(50,10,100,80);
Fl_Box *message = new Fl_Box(10,110,230,30);
message->label("callbacks will show up here ...");
win1->end();
spinner->callback(spinner_cb,message);
win1->show(argc,argv);
return Fl::run();
}
--- snip ---
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk