NAME

Fl::Event - Event Loop Related Functions

Synopsis

use Fl qw[:event];
# ...
run();

Description

The :event import tag brings all of these functions into your namespace.

Functions

The following functions are exposed.

belowmouse(...)

my $widget = Fl::belowmouse();
Fl::belowmouse($window);

Get or set the widget below the mouse.

Setting this value is This is for highlighting buttons. It is not used to send FL_PUSH or FL_MOVE directly, for several obscure reasons, but those events typically go to this widget. This is also the first widget tried for FL_SHORTCUT events.

If you change the belowmouse widget, the previous one and all parents (that don't contain the new widget) are sent FL_LEAVE events. Changing this does not send FL_ENTER to this or any widget, because sending FL_ENTER is supposed to test if the widget wants the mouse (by it returning non-zero from handle()).

run( )

...
$window->show();
Fl::run();

As long as any windows are displayed, this calles Fl::wait() repeatedly.

When all windows are closed, it returns zero.

check( )

while (!calculation_done()) {
    calculate();
    Fl::check();
    last if user_hit_abort_button();
}

This is the same as calling Fl::wait(0).

Calling this during (for example) a long calculation process will keep the screen up to date and the interface responsive without forking or threading.

This returns non-zero if any windws are displayed. Otherwise, zero is returned.

wait(...)

Fl::wait();
Fl::wait(2);

Waits until 'something happens' and then returns.

Call this repeatedly to 'run' your program. You can also check what happened each time after this returns which is quite useful for managing program state.

What this really does is call all idle callbacks, all elapsed timeouts, call Fl::flush() to get the screen to update, and then wait some time (zero if the are idle callbacks, the sortest of all pending timeouts, or infinity) for any events from the user or any Fl::ad_fd() callbacks. It then handles the events and calls the callbacks and then returns.

The return value of Fl::wait() is non-zero if there are any visible windows.

Fl::wait($time) waits a maxium of $time seconds. It may return much sooner if something happens.

The return value is positive if an event or fd happens before the time elapsed. It is zero if nothing happens (on Windows this will only return zero if $time is zero). It is negative if an error occurs (this will happen on X11 if a signal happens).

ready()

while (!calculation_done()) {
    calculate();
    if (Fl::ready()) {
        do_expensive_cleanup();
        Fl::check();
        last if user_hit_abort_button();
    }
}

This is similar to Fl::check() except this does not call Fl::flush() or any callbacks, which is useful if your program is in a state where such callbacks are illegal.

This returns true if Fl::check() would do anything (it will continue to return true until you call Fl::check() or Fl::wait()).

event( )

my event = Fl::event();

Returns the last event that was processed.

This can be used to determine if a callback is being done in response to a keypress, mouse click, etc.

LICENSE

Copyright (C) Sanko Robinson.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

AUTHOR

Sanko Robinson <sanko@cpan.org>