#include "FL_API.h"
Namespaces | |
namespace | fltk |
fltk/events.h | |
enum | { fltk::NO_EVENT = 0, fltk::PUSH = 1, fltk::RELEASE = 2, fltk::ENTER = 3, fltk::LEAVE = 4, fltk::DRAG = 5, fltk::FOCUS = 6, fltk::UNFOCUS = 7, fltk::KEY = 8, fltk::KEYUP = 9, fltk::FOCUS_CHANGE = 10, fltk::MOVE = 11, fltk::SHORTCUT = 12, fltk::DEACTIVATE = 13, fltk::ACTIVATE = 14, fltk::HIDE = 15, fltk::SHOW = 16, fltk::PASTE = 17, fltk::TIMEOUT = 18, fltk::MOUSEWHEEL = 19, fltk::DND_ENTER = 20, fltk::DND_DRAG = 21, fltk::DND_LEAVE = 22, fltk::DND_RELEASE = 23, fltk::TOOLTIP = 24 } |
enum | { fltk::LeftButton = 1, fltk::MiddleButton = 2, fltk::RightButton = 3, fltk::WheelUp = 4, fltk::WheelDown = 5, fltk::WheelLeft = 6, fltk::WheelRight = 7, fltk::SpaceKey = 32, fltk::BackSpaceKey = 0xff08, fltk::TabKey = 0xff09, fltk::ClearKey = 0xff0b, fltk::ReturnKey = 0xff0d, fltk::PauseKey = 0xff13, fltk::ScrollLockKey = 0xff14, fltk::EscapeKey = 0xff1b, fltk::HomeKey = 0xff50, fltk::LeftKey = 0xff51, fltk::UpKey = 0xff52, fltk::RightKey = 0xff53, fltk::DownKey = 0xff54, fltk::PageUpKey = 0xff55, fltk::PageDownKey = 0xff56, fltk::EndKey = 0xff57, fltk::PrintKey = 0xff61, fltk::InsertKey = 0xff63, fltk::MenuKey = 0xff67, fltk::HelpKey = 0xff68, fltk::NumLockKey = 0xff7f, fltk::Keypad = 0xff80, fltk::KeypadEnter = Keypad+'\r', fltk::MultiplyKey = Keypad+'*', fltk::AddKey = Keypad+'+', fltk::SubtractKey = Keypad+'-', fltk::DecimalKey = Keypad+'.', fltk::DivideKey = Keypad+'/', fltk::Keypad0 = Keypad+'0', fltk::Keypad1 = Keypad+'1', fltk::Keypad2 = Keypad+'2', fltk::Keypad3 = Keypad+'3', fltk::Keypad4 = Keypad+'4', fltk::Keypad5 = Keypad+'5', fltk::Keypad6 = Keypad+'6', fltk::Keypad7 = Keypad+'7', fltk::Keypad8 = Keypad+'8', fltk::Keypad9 = Keypad+'9', fltk::KeypadLast = 0xffbd, fltk::F0Key = 0xffbd, fltk::F1Key = F0Key+1, fltk::F2Key = F0Key+2, fltk::F3Key = F0Key+3, fltk::F4Key = F0Key+4, fltk::F5Key = F0Key+5, fltk::F6Key = F0Key+6, fltk::F7Key = F0Key+7, fltk::F8Key = F0Key+8, fltk::F9Key = F0Key+9, fltk::F10Key = F0Key+10, fltk::F11Key = F0Key+11, fltk::F12Key = F0Key+12, fltk::LastFunctionKey = F0Key+35, fltk::LeftShiftKey = 0xffe1, fltk::RightShiftKey = 0xffe2, fltk::LeftCtrlKey = 0xffe3, fltk::RightCtrlKey = 0xffe4, fltk::CapsLockKey = 0xffe5, fltk::LeftMetaKey = 0xffe7, fltk::RightMetaKey = 0xffe8, fltk::LeftAltKey = 0xffe9, fltk::RightAltKey = 0xffea, fltk::DeleteKey = 0xffff } |
enum | { fltk::SHIFT = 0x00010000, fltk::CAPSLOCK = 0x00020000, fltk::CTRL = 0x00040000, fltk::ALT = 0x00080000, fltk::NUMLOCK = 0x00100000, fltk::META = 0x00400000, fltk::SCROLLLOCK = 0x00800000, fltk::BUTTON1 = 0x01000000, fltk::BUTTON2 = 0x02000000, fltk::BUTTON3 = 0x04000000, fltk::BUTTON4 = 0x08000000, fltk::BUTTON5 = 0x10000000, fltk::BUTTON6 = 0x20000000, fltk::BUTTON7 = 0x40000000, fltk::ANY_BUTTON = 0xff000000, fltk::ACCELERATOR = ALT, fltk::COMMAND = CTRL, fltk::OPTION = ALT|META } |
enum | { fltk::DEVICE_MOUSE = 0, fltk::DEVICE_STYLUS = 1, fltk::DEVICE_ERASER = 2, fltk::DEVICE_CURSOR = 3, fltk::DEVICE_AIRBRUSH = 4, fltk::DEVICE_TOUCH = 5 } |
unsigned | fltk::BUTTON (int n) |
int | fltk::event () |
int | fltk::event_x () |
int | fltk::event_y () |
int | fltk::event_dx () |
int | fltk::event_dy () |
int | fltk::event_x_root () |
int | fltk::event_y_root () |
int | fltk::event_clicks () |
void | fltk::event_clicks (int i) |
bool | fltk::event_is_click () |
void | fltk::event_is_click (bool) |
unsigned | fltk::event_state () |
bool | fltk::event_state (unsigned i) |
unsigned | fltk::event_key () |
unsigned | fltk::event_button () |
bool | fltk::event_key_state (unsigned) |
const char * | fltk::event_text () |
unsigned | fltk::event_length () |
unsigned | fltk::event_key_repeated () |
float | fltk::event_pressure () |
float | fltk::event_x_tilt () |
float | fltk::event_y_tilt () |
int | fltk::event_device () |
bool | fltk::event_inside (const Rectangle &) |
bool | fltk::compose (int &del) |
void | fltk::compose_reset () |
bool | fltk::try_shortcut () |
const char * | fltk::key_name (unsigned key) |
unsigned | fltk::key (const char *name) |
unsigned | fltk::foreachShortcut (const Widget *, ShortcutFunctor &) |
unsigned | fltk::foreachShortcut (ShortcutFunctor &f) |
bool | fltk::get_key_state (unsigned) |
void | fltk::get_mouse (int &, int &) |
bool | fltk::warp_mouse (int, int) |
bool | fltk::handle (int, Window *) |
void | fltk::add_event_handler (int(*h)(int, Window *)) |
Widget * | fltk::belowmouse () |
void | fltk::belowmouse (Widget *) |
void | fltk::belowmouse (Widget &w) |
Widget * | fltk::pushed () |
void | fltk::pushed (Widget *) |
void | fltk::pushed (Widget &w) |
Widget * | fltk::focus () |
void | fltk::focus (Widget *) |
void | fltk::focus (Widget &w) |
void | fltk::copy (const char *stuff, int len, bool clipboard=false) |
void | fltk::paste (Widget &receiver, bool clipboard=false) |
bool | fltk::dnd () |
void | fltk::modal (Widget *, bool grab=false) |
Widget * | fltk::modal () |
bool | fltk::grab () |
void | fltk::exit_modal () |
bool | fltk::exit_modal_flag () |
const char * | fltk::event_name (int event) |
return the corresponding str of an event, should not consume memory if api is not used |
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.