On 8/28/22 12:45, Justin Named wrote:
How can I connect to fltk cycle? I think make it with custom widget, hide my code in methods what fltk call for handle/drawing. Is this right way?
I'm guessing you mean the "FLTK application loop".
Yes, if you want to have your code triggered during widget
drawing, you'd overload your widget's draw() method.
And if you want to have your code triggered during
mouse/keyboard events, you'd overload your widget's handle()
method.
When overloading 'handle(int event)', be sure to call
the underlying widget's handle() method
or you'll prevent events from being delivered to it. Example:
class YourClass : public Fl_Button {
..
int handle(int event) {
int ret =
Fl_Button::handle(event); // IMPORTANT: PASS EVENT TO BASE
CLASS!
switch (event) {
.. do your stuff here ..
If you handle an event, set 'ret =
1' so FLTK knows
not to try to send the event to
other widgets.
}
return ret; // IMPORTANT:
PASS RETURN VALUE BACK TO FLTK
}
};