On 06.02.2012 12:30, M3taSpl0it wrote:
> I appreciate the time and help of yours but still confused. I'm fairly good 
> in C++ but eager to know in deep the working of fltk.
>
>>> I want to know when some event occurs, the information is sent to FLTK 
>>> window, Which has two version of handle() and handle(int x) (I'm not even 
>>> sure what they do, just know they get/set the events). I am also not sure 
>>> that every widget also got the same handle() versions?. Which in turn calls 
>>> the some other functions to call my call_back() to handle the event which 
>>> was set by my like FL_widget_mine->callback(Handle_it);
>>
>> Each (widget) class has its own handle(int event) method. All events
>> are delivered to the widget's handle method. The widget (class) then
>> does some actions or ignores the event. Eventually, the event() method
>> calls the callback, if something happened that is "important enough"
>> to call the user's callback function. For an input widget, this is
>> when the contents was changed, and/or the widget is left (e.g. with
>> a mouse click on another widget or by typing tab). You can change
>> this for any widget by using the when() method in a limited way,
>> depending on the class's ability (see the particular docs).
>
> "All events are delivered to the widget's handle method". Please be more 
> precise with working. I want to know Who deleviers the event to widget and 
> using what syntax, handle() or handle(int) ?

Where did you find a handle() method, as opposed to handle(int event)?

I don't think there is one as a class method, but only as an internal
function in the FLTK core. But maybe I'm wrong...

Anyway, to answer your question: When you call Fl::run(), you establish
the FLTK event loop that waits for OS events (I won't be more precise
here, because this is an OS dependent beast). Whenever FLTK (the core)
receives an event, it usually also gets a window id and sends the event
to the window specified by the OS. There are exceptions for modal
windows, but this is not important here. Eventually the Fl_Window's
handle(int event) method is called.

Now the window's handle method (I always mean handle(int event) here
and later) dispatches the event and decides what to do. Usually this
will call its parent (Fl_Group) class's handle method. Fl_Group will
then either handle the event directly, or determine to which child the
event is related and call this child's handle method. If this child is
an Fl_Group (derived) widget, this will recursively go on.

As I wrote before, eventually a widget may decide that the callback
should be called and calls the callback function registered by the
user.

Albrecht
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to