Odds and ends

This document is for things that didn't fit elsewhere or are too gross to add to the main reference.


flua_require(filename) provides a simple "require" mechanism. filename is searched for in the environment variable FLUA_PATH; if it doesn't exist it defaults to the current directory, a local installation directory and a system directory (typically .:/usr/local/lib/flua-1.0:/usr/lib/flua-1.0). A file will only be loaded once by this mechanism.

Default initializers

The standard widget constructor uses the class table Fl_Widget.initializers (Fl_Button.initializers...) to set initial properties on widgets created. Properties specified directly in the constructor take precedence. This mechanism can be used to set a standard look across an application.

The class table Fl_Widget.ignore_initializers removes inherited initializers to restore defaults on instances and subclasses; if an entry exists, any inherited initializer is ignored.

Standard dialogs

The standard FLTK dialog functions fl_message, fl_alert, fl_ask are mapped to Lua as taking a single string argument, not a format code. fl_input, fl_password, fl_file_chooser exist. fl_choice's varargs is too tedious to map so far.

Event and timeout handlers

Somewhat raw access to Fl::add_handler() and Fl::add_timeout() is available for people who really need it.

fl_start_event_handler() installs a global event handler. Whenever it fires, Lua FLTK calls the global Lua function fltk_event_handler(n) where n is the Event code. It should return no values to reject the event or a true value to accept it.

fl_start_timeout_handler(time, n) starts a timeout handler that will fire in time seconds, where time is a floating point number. When it fires, it calls the global Lua function fltk_timeout_handler(n) where n is the integer originally passed to fl_start_timeout_handler().

Neither of these is particularly friendly, but as primitives they're strong enough to build all other global handler and timeout behavior with enough Lua code.

Jay Carlson
Last modified: Sun Aug 12 21:40:12 EDT 2001