fltk/events.h File Reference


Namespaces

namespace  fltk

fltk/events.h

enum  {
  fltk::NO_EVENT, fltk::PUSH, fltk::RELEASE, fltk::ENTER,
  fltk::LEAVE, fltk::DRAG, fltk::FOCUS, fltk::UNFOCUS,
  fltk::KEY, fltk::KEYUP, fltk::FOCUS_CHANGE, fltk::MOVE,
  fltk::SHORTCUT, fltk::DEACTIVATE, fltk::ACTIVATE, fltk::HIDE,
  fltk::SHOW, fltk::PASTE, fltk::TIMEOUT, fltk::MOUSEWHEEL,
  fltk::DND_ENTER, fltk::DND_DRAG, fltk::DND_LEAVE, fltk::DND_RELEASE,
  fltk::TOOLTIP
}
enum  {
  fltk::LeftButton, fltk::MiddleButton, fltk::RightButton, fltk::SpaceKey,
  fltk::BackSpaceKey, fltk::TabKey, fltk::ClearKey, fltk::ReturnKey,
  fltk::PauseKey, fltk::ScrollLockKey, fltk::EscapeKey, fltk::HomeKey,
  fltk::LeftKey, fltk::UpKey, fltk::RightKey, fltk::DownKey,
  fltk::PageUpKey, fltk::PageDownKey, fltk::EndKey, fltk::PrintKey,
  fltk::InsertKey, fltk::MenuKey, fltk::HelpKey, fltk::NumLockKey,
  fltk::Keypad, fltk::KeypadEnter, fltk::MultiplyKey, fltk::AddKey,
  fltk::SubtractKey, fltk::DecimalKey, fltk::DivideKey, fltk::Keypad0,
  fltk::Keypad1, fltk::Keypad2, fltk::Keypad3, fltk::Keypad4,
  fltk::Keypad5, fltk::Keypad6, fltk::Keypad7, fltk::Keypad8,
  fltk::Keypad9, fltk::KeypadLast, fltk::F0Key, fltk::F1Key,
  fltk::F2Key, fltk::F3Key, fltk::F4Key, fltk::F5Key,
  fltk::F6Key, fltk::F7Key, fltk::F8Key, fltk::F9Key,
  fltk::F10Key, fltk::F11Key, fltk::F12Key, fltk::LastFunctionKey,
  fltk::LeftShiftKey, fltk::RightShiftKey, fltk::LeftCtrlKey, fltk::RightCtrlKey,
  fltk::CapsLockKey, fltk::LeftMetaKey, fltk::RightMetaKey, fltk::LeftAltKey,
  fltk::RightAltKey, fltk::DeleteKey, LeftAccKey, RightAccKey,
  LeftCmdKey, RightCmdKey
}
enum  {
  fltk::SHIFT, fltk::CAPSLOCK, fltk::CTRL, fltk::ALT,
  fltk::NUMLOCK, fltk::META, fltk::SCROLLLOCK, fltk::BUTTON1,
  fltk::BUTTON2, fltk::BUTTON3, fltk::ANY_BUTTON, fltk::ACCELERATOR,
  fltk::COMMAND, fltk::OPTION
}
enum  {
  fltk::DEVICE_MOUSE, fltk::DEVICE_STYLUS, fltk::DEVICE_ERASER, fltk::DEVICE_CURSOR,
  fltk::DEVICE_AIRBRUSH, fltk::DEVICE_TOUCH
}
void fltk::add_event_handler (int(*h)(int, Window *))
void fltk::belowmouse (Widget &w)
void fltk::belowmouse (Widget *)
Widget * fltk::belowmouse ()
unsigned fltk::BUTTON (int n)
bool fltk::compose (int &del)
void fltk::compose_reset ()
void fltk::copy (const char *stuff, int len, bool clipboard=false)
bool fltk::dnd ()
int fltk::event ()
unsigned fltk::event_button ()
void fltk::event_clicks (int i)
int fltk::event_clicks ()
int fltk::event_device ()
int fltk::event_dx ()
int fltk::event_dy ()
bool fltk::event_inside (const Rectangle &)
void fltk::event_is_click (bool)
bool fltk::event_is_click ()
unsigned fltk::event_key ()
unsigned fltk::event_key_repeated ()
bool fltk::event_key_state (unsigned)
unsigned fltk::event_length ()
const char * fltk::event_name (int event)
 return the corresponding str of an event, should not consume memory if api is not used
float fltk::event_pressure ()
bool fltk::event_state (unsigned i)
unsigned fltk::event_state ()
const char * fltk::event_text ()
int fltk::event_x ()
int fltk::event_x_root ()
float fltk::event_x_tilt ()
int fltk::event_y ()
int fltk::event_y_root ()
float fltk::event_y_tilt ()
void fltk::exit_modal ()
bool fltk::exit_modal_flag ()
void fltk::focus (Widget &w)
void fltk::focus (Widget *)
Widget * fltk::focus ()
unsigned fltk::foreachShortcut (ShortcutFunctor &f)
unsigned fltk::foreachShortcut (const Widget *, ShortcutFunctor &)
bool fltk::get_key_state (unsigned)
void fltk::get_mouse (int &, int &)
bool fltk::grab ()
bool fltk::handle (int, Window *)
unsigned fltk::key (const char *name)
const char * fltk::key_name (unsigned key)
Widget * fltk::modal ()
void fltk::modal (Widget *, bool grab=false)
void fltk::paste (Widget &receiver, bool clipboard=false)
void fltk::pushed (Widget &w)
void fltk::pushed (Widget *)
Widget * fltk::pushed ()
bool fltk::try_shortcut ()
bool fltk::warp_mouse (int, int)

Detailed Description

FLTK Events are identified by the integer argument passed to the fltk::Widget::handle() virtual method. Often a widget will modify this number before passing it to it's children.

Fltk only thinks about one event at a time. Therefore all of the other data about the event is stored in static memory, rather than a typical "event structure". It is accessed with fast inline functions of the form fltk::event_*.

FLTK has very simple rules for sending events to widgets. The major unusual aspect of FLTK is that widgets indicate if they "handled" an event by returning non-zero from their fltk::Widget::handle() method. If they return zero, FLTK can then try the event elsewhere. This eliminates the need for "interests" (event masks or tables), and this is the main reason FLTK is much smaller than other toolkits.

Most events are sent to the outermost fltk::Window containing the event, and those widgets are responsible for finding and sending the events to child widgets. Some events are sent directly to fltk::Widgets, this is controlled by the following methods, which the container widgets are required to call:

If all the widgets that FLTK tries to send an event to return zero, then you can add global functions that FLTK will call with these events. This is done with fltk::add_event_handler()

You can generate fake events by calling handle(int) on the correct widgets (usually a window). Currently you can change the values returned by the fltk::event_*() functions by storing the desired value into the static variables fltk::e_*, but this may change in future versions.


Wed Jun 17 08:53:24 2009. FLTK ©2007 Bill Spitzak and others.
Permission is granted to reproduce this manual or any portion for any purpose, provided this copyright and permission notice are preserved.