|
|
> As a test, and to learn about FLTK and classes, I am trying to make a
> dial that control a value input - very simular to the "adjuster" example
> (part of the FLTK distribution), except that I have put the interface
> into a class. The class they belong to is called Tempo, and the controls
> are named "tempo_dial" and "tempo_input". When the dial is changed,
> the callback goes to a global function, tempo_cb(Fl_Dial *o, void *v).
> So here's my problem: how to transfer the value from the tempo_dial
> (which I can read) to the tempo_input? I have made a global variable that
> points to my userinterface, and tried to use the pointer to read out
> the value from within the callback, but just setting up the connection
> proved more difficult than I had expected. Fl_Value_Input *obj =
> (Fl_Value_Input*)tempo_class->tempo_input; It compiles, but results
> in an access violation - what am I doing wrong here? And could there be
> an alternative solution ?
Hi,
Here is probable solution.
For example if we have:
Fl_Dial *tempo_dial;
Fl_Value_Input *tempo_input;
then:
tempo_dial->callback(dial_cb, tempo_input);
where dial_cb is:
void dial_cb(Fl_Widget*, void* ti)
{
Fl_Value_Input* tempo_input = (Fl_Value_Input*)ti;
tempo_input->value(some_global_value);
}
Now, displayed value inside Fl_Value_Input is controlled by Fl_Dial.
'some_global_value' can be set/changed inside dial_cb or somewhere else.
Works ?
[ Direct Link to Message ] | |
|
| |