|
|
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
}
};
--
You received this message because you are subscribed to the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkgeneral/0eab6f47-607c-be06-9f34-01b8ce86fa37%40seriss.com.
[ Direct Link to Message ] | |
|
| |