FLTK logo

Re: [fltk.general] Fltk app cycle

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.general  ]
 
Previous Message ]New Message | Reply ]Next Message ]

Re: Fltk app cycle Greg Ercolano Aug 28, 2022  
 

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 ]
 
     
Previous Message ]New Message | Reply ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.