Events

Events are identified the small integer argument passed to the handle() method on an object. Unless you are subclassing an object, you cannot see this event type. Other information about the most recent event is stored in static locations and aquired by calling Fl::event_*(). This other information remains valid until another event is read from the X server (and thus is valid inside a callback or other function called from handle()).

Event types as passed to Fl_Object::handle(int):

FL_PUSH (1)

FL_DRAG (5)

FL_RELEASE (2)

FL_ENTER (3)

FL_MOVE (10)

FL_LEAVE (4)

FL_FOCUS (6)

FL_UNFOCUS (7)

FL_KEYBOARD (8)

FL_SHORTCUT (11)

FL_DEACTIVATE (13)

FL_ACTIVATE (14)

FL_HIDE (15)

FL_SHOW (16)

FL_PASTE (17)

FL_SELECTIONCLEAR (18)

Fl::event_*() methods

FL keeps the information about the most recent event in static storage. This information is good until the next event is processed. Thus it is valid inside handle() and callback() methods.

These are all trivial inline functions and thus very fast and small. The data is stored in static locations and remains valid until the next X event is handled.

int Fl::event_button();

int Fl::event_x()
int Fl::event_y()

int Fl::event_x_root()
int Fl::event_y_root()

unsigned int Fl::event_state()

int Fl::event_shift();
int Fl::event_capslock();
int Fl::event_ctrl();
int Fl::event_alt();

int Fl::event_buttons();
int Fl::event_button1();
int Fl::event_button2();
int Fl::event_button3();

int Fl::event_key()

int Fl::event_keypad()

char * Fl::event_text()

int Fl::event_is_click()

void Fl::event_is_click(0)

int Fl::event_clicks()

void Fl::event_clicks(int)

int Fl::event_inside(const Fl_Object *) const ;
int Fl::event_inside(int,int,int,int);

int Fl::test_shortcut(const char *) const ;

ulong Fl::event_time()

extern XEvent fl_xvent;

Event Propagation

FL follows very simple and unchangeable rules for sending events. The major innovation is that objects can indicate (by returning 0 from the handle() method) that they are not interested in an event, and FL can then send that event elsewhere. This eliminates the need for "interests" (event masks or tables), and this is probably the main reason FL is much smaller than other X toolkits.

Most events are sent directly to the handle() method of the Fl_Window that X says they belong to. The window (actually the Fl_Group that Fl_Window is a subclass of) is responsible for sending the events on to any child objects. To make the Fl_Group code somewhat easier, FL sends some events (FL_DRAG, FL_RELEASE, FL_KEYBOARD, FL_SHORTCUT, FL_UNFOCUS, FL_LEAVE) directly to leaf objects. These procedures control those leaf objects:

Fl_Object *Fl::focus() const;
void Fl::focus(Fl_Object *);

int Fl_Object::take_focus();

Fl_Object *Fl::belowmouse() const;
void Fl::belowmouse(Fl_Object *);

Fl_Object *Fl::pushed() const;
void Fl::pushed(Fl_Object *);

void Fl::add_handler(int (*f)(int));

void Fl::grab()

void Fl::release()

(back to contents)