> If you have an Fl_Choice widget, and pop up its menu, you
> can dismiss the menu sub-window by clicking anywhere at
> all, so it seems fltk can handle it somehow.
> 
> Here's another example.  Without the sub-window, grab()
> makes all the events visible, as expected. Compare it to
> the original.
>
> Doesn't that mean it's supposed to get events external to the window?

Yes, but this looks under the hood little bit different. When you start
your application, you usually have main window and it's children (or widgets).

This means that fltk internally build some kind of tree so it can communicate 
with them, and eventually when main application quits, nicely 
delete every one of them.

Those childrens can be sub-windows too; no matter where they are placed
(even on another screen), as long as fltk see them as it's children, it can
send to them and receive from them events. Fl::grab() will instruct
main window (you can see it as root in above tree) to 'route' events
to one of it's sub-windows.

Hoping now is little bit clear how Fl::grab() works :-)

On other hand, communication between two applications (or two instances
of the same), can be accomplished only via either system specific
messages or some kind of IPC calls. For example, when you starts two
instances of fluid, they can't send events to each other via plain fltk
calls.

The same applies for window manager borders (you can see them as
children of window manager application) so to get events from them you
have to communicate with window manager itself.

Another solution exists and is extremely system specific.
On X11 there is a way to listen specific events that occurs on the screen; 
registering your own event handler via Fl::add_handler(), events will be 
reported 
there for all visible windows on that screen (not fltk ones only) and you must 
find 
out who triggered them; this can be in some cases simple, but in some very 
tricky, 
not to say how this solution introduce a lot of event noise in 
Fl::add_handler().
Those events will not be fltk-like (FL_PUSH and etc.), but system one,
like KeyPress, KeyRelease...)

To complicate matter more, events in main fltk application window will be 
reported in
Fl_Window::handle(), but not in Fl::add_handler().

I'm hoping this quick explaination didn't introduce more confusion :-).

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

Reply via email to