From 87dd7f0d23eba5c09e71ec6efeb34c6844f5e95f Mon Sep 17 00:00:00 2001 From: Michael R Sweet Date: Tue, 29 Dec 1998 14:21:17 +0000 Subject: Revised documentation files. git-svn-id: file:///fltk/svn/fltk/trunk@177 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- documentation/events.html | 499 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 499 insertions(+) create mode 100644 documentation/events.html (limited to 'documentation/events.html') diff --git a/documentation/events.html b/documentation/events.html new file mode 100644 index 000000000..b4b5f1513 --- /dev/null +++ b/documentation/events.html @@ -0,0 +1,499 @@ + + + +

4 - Handling Events

+ +This chapter discusses the FLTK event model and how to handle events in your program or +widget. + +

The FLTK Event Model

+ +

Mouse Events

+ +

FL_PUSH

+ +

FL_RELEASE

+ +

FL_DRAG

+ +

FL_MOVE

+ +

Keyboard Events

+ +

FL_KEYBOARD

+ +

FL_SHORTCUT

+ +

Widget Events

+ +

FL_ACTIVATE

+ +

FL_DEACTIVATE

+ +

FL_HIDE

+ +

FL_SHOW

+ +

FL_FOCUS

+ +

FL_UNFOCUS

+ +

FL_ENTER

+ +

FL_LEAVE

+ +

FL_PASTE

+ +

FL_SELECTIONCLEAR

+ + + +Events in Fltk + +

Events in Fltk

+ +

Events are identified the small integer argument passed to the Fl_Widget::handle() virtual method. +Other information about the most recent event is stored in static +locations and aquired by calling Fl::event_*(). This static +information remains valid until the next event is read from the X +server (that is, it is ok to look at it outside the handle() method). + +

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

+ +Fltk 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()

void Fl::get_mouse(int &,int &)

ulong Fl::event_state(); +
unsigned int Fl::event_state(int);

int Fl::event_key(); +
int Fl::event_key(int); +
int Fl::get_key(int);

char * Fl::event_text()

char * Fl::event_length()

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_Widget *) const ; +
int Fl::event_inside(int,int,int,int);

int Fl::test_shortcut(ulong) const ;

+ + +

Event Propagation

+ +

Fltk follows very simple and unchangeable rules for sending events. +The major innovation is that widgets can indicate (by returning 0 from +the handle() method) that they are not interested in an event, and fltk +can then send that event elsewhere. This eliminates the need for +"interests" (event masks or tables), and this is probably the main +reason fltk 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 widgets. To make the Fl_Group code +somewhat easier, fltk sends some events (FL_DRAG, FL_RELEASE, +FL_KEYBOARD, FL_SHORTCUT, FL_UNFOCUS, FL_LEAVE) directly to leaf +widgets. These procedures control those leaf widgets: + + +

Fl_Widget *Fl::focus() const; +
void Fl::focus(Fl_Widget *);

int Fl_Widget::take_focus();

Fl_Widget *Fl::belowmouse() const; +
void Fl::belowmouse(Fl_Widget *);

Fl_Widget *Fl::pushed() const; +
void Fl::pushed(Fl_Widget *);

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

Fl_Window* Fl::modal();

void Fl::grab(Fl_Window&);
+Fl_Window* Fl::grab();

void Fl::release()

(back to contents) -- cgit v1.2.3