FLTK 1.3.3
|
Fl class events handling API declared in <FL/Fl.H> More...
Functions | |
static void | Fl::add_handler (Fl_Event_Handler h) |
Install a function to parse unrecognized events. More... | |
static void | Fl::add_system_handler (Fl_System_Handler h, void *data) |
Install a function to intercept system events. More... | |
static Fl_Widget * | Fl::belowmouse () |
Gets the widget that is below the mouse. More... | |
static void | Fl::belowmouse (Fl_Widget *) |
Sets the widget that is below the mouse. More... | |
static int | Fl::compose (int &del) |
Any text editing widget should call this for each FL_KEYBOARD event. More... | |
static void | Fl::compose_reset () |
If the user moves the cursor, be sure to call Fl::compose_reset(). More... | |
static void | Fl::disable_im () |
Disables the system input methods facilities. More... | |
static void | Fl::enable_im () |
Enables the system input methods facilities. More... | |
static int | Fl::event () |
Returns the last event that was processed. More... | |
static int | Fl::event_alt () |
Returns non-zero if the Alt key is pressed. More... | |
static int | Fl::event_button () |
Gets which particular mouse button caused the current event. More... | |
static int | Fl::event_button1 () |
Returns non-zero if mouse button 1 is currently held down. More... | |
static int | Fl::event_button2 () |
Returns non-zero if button 2 is currently held down. More... | |
static int | Fl::event_button3 () |
Returns non-zero if button 3 is currently held down. More... | |
static int | Fl::event_buttons () |
Returns the mouse buttons state bits; if non-zero, then at least one button is pressed now. More... | |
static int | Fl::event_clicks () |
Returns non zero if we had a double click event. More... | |
static void | Fl::event_clicks (int i) |
Manually sets the number returned by Fl::event_clicks(). More... | |
static void * | Fl::event_clipboard () |
During an FL_PASTE event of non-textual data, returns a pointer to the pasted data. More... | |
static const char * | Fl::event_clipboard_type () |
Returns the type of the pasted data during an FL_PASTE event. More... | |
static int | Fl::event_command () |
Returns non-zero if the FL_COMMAND key is pressed, either FL_CTRL or on OSX FL_META. More... | |
static int | Fl::event_ctrl () |
Returns non-zero if the Control key is pressed. More... | |
static void | Fl::event_dispatch (Fl_Event_Dispatch d) |
Set a new event dispatch function. More... | |
static Fl_Event_Dispatch | Fl::event_dispatch () |
Return the current event dispatch function. | |
static int | Fl::event_dx () |
Returns the current horizontal mouse scrolling associated with the FL_MOUSEWHEEL event. More... | |
static int | Fl::event_dy () |
Returns the current vertical mouse scrolling associated with the FL_MOUSEWHEEL event. More... | |
static int | Fl::event_inside (int, int, int, int) |
Returns whether or not the mouse event is inside the given rectangle. More... | |
static int | Fl::event_inside (const Fl_Widget *) |
Returns whether or not the mouse event is inside a given child widget. More... | |
static int | Fl::event_is_click () |
Returns non-zero if the mouse has not moved far enough and not enough time has passed since the last FL_PUSH or FL_KEYBOARD event for it to be considered a "drag" rather than a "click". More... | |
static void | Fl::event_is_click (int i) |
Clears the value returned by Fl::event_is_click(). More... | |
static int | Fl::event_key () |
Gets which key on the keyboard was last pushed. More... | |
static int | Fl::event_key (int key) |
Returns true if the given key was held down (or pressed) during the last event. More... | |
static int | Fl::event_length () |
Returns the length of the text in Fl::event_text(). More... | |
static int | Fl::event_original_key () |
Returns the keycode of the last key event, regardless of the NumLock state. More... | |
static int | Fl::event_shift () |
Returns non-zero if the Shift key is pressed. More... | |
static int | Fl::event_state () |
This is a bitfield of what shift states were on and what mouse buttons were held down during the most recent event. More... | |
static int | Fl::event_state (int i) |
See int event_state() | |
static const char * | Fl::event_text () |
Returns the text associated with the current event, including FL_PASTE or FL_DND_RELEASE events. More... | |
static int | Fl::event_x () |
Returns the mouse position of the event relative to the Fl_Window it was passed to. | |
static int | Fl::event_x_root () |
Returns the mouse position on the screen of the event. More... | |
static int | Fl::event_y () |
Returns the mouse position of the event relative to the Fl_Window it was passed to. | |
static int | Fl::event_y_root () |
Returns the mouse position on the screen of the event. More... | |
static Fl_Widget * | Fl::focus () |
Gets the current Fl::focus() widget. More... | |
static void | Fl::focus (Fl_Widget *) |
Sets the widget that will receive FL_KEYBOARD events. More... | |
static int | Fl::get_key (int key) |
Returns true if the given key is held down now. More... | |
static void | Fl::get_mouse (int &, int &) |
Return where the mouse is on the screen by doing a round-trip query to the server. More... | |
static int | Fl::handle (int, Fl_Window *) |
Handle events from the window system. More... | |
static int | Fl::handle_ (int, Fl_Window *) |
Handle events from the window system. More... | |
static Fl_Widget * | Fl::pushed () |
Gets the widget that is being pushed. More... | |
static void | Fl::pushed (Fl_Widget *) |
Sets the widget that is being pushed. More... | |
static void | Fl::remove_handler (Fl_Event_Handler h) |
Removes a previously added event handler. More... | |
static void | Fl::remove_system_handler (Fl_System_Handler h) |
Removes a previously added system event handler. More... | |
static int | Fl::test_shortcut (Fl_Shortcut) |
Tests the current event, which must be an FL_KEYBOARD or FL_SHORTCUT, against a shortcut value (described in Fl_Button). More... | |
Variables | |
const char *const | fl_eventnames [] |
This is an array of event names you can use to convert event numbers into names. More... | |
const char *const | fl_fontnames [] |
This is an array of font names you can use to convert font numbers into names. More... | |
Fl class events handling API declared in <FL/Fl.H>
|
static |
Install a function to parse unrecognized events.
If FLTK cannot figure out what to do with an event, it calls each of these functions (most recent first) until one of them returns non-zero. If none of them returns non-zero then the event is ignored. Events that cause this to be called are:
|
static |
Install a function to intercept system events.
FLTK calls each of these functions as soon as a new system event is received. The processing will stop at the first function to return non-zero. If all functions return zero then the event is passed on for normal handling by FLTK.
Each function will be called with a pointer to the system event as the first argument and data
as the second argument. The system event pointer will always be void *, but will point to different objects depending on the platform:
ha | The event handler function to register |
data | User data to include on each call |
|
inlinestatic |
Gets the widget that is below the mouse.
|
static |
Sets the widget that is below the mouse.
This is for highlighting buttons. It is not used to send FL_PUSH or FL_MOVE directly, for several obscure reasons, but those events typically go to this widget. This is also the first widget tried for FL_SHORTCUT events.
If you change the belowmouse widget, the previous one and all parents (that don't contain the new widget) are sent FL_LEAVE events. Changing this does not send FL_ENTER to this or any widget, because sending FL_ENTER is supposed to test if the widget wants the mouse (by it returning non-zero from handle()).
|
static |
Any text editing widget should call this for each FL_KEYBOARD event.
Use of this function is very simple.
If true is returned, then it has modified the Fl::event_text() and Fl::event_length() to a set of bytes to insert (it may be of zero length!). It will also set the "del" parameter to the number of bytes to the left of the cursor to delete, this is used to delete the results of the previous call to Fl::compose().
If false is returned, the keys should be treated as function keys, and del is set to zero. You could insert the text anyways, if you don't know what else to do.
On the Mac OS platform, text input can involve marked text, that is, temporary text replaced by other text during the input process. This occurs, e.g., when using dead keys or when entering CJK characters. Text editing widgets should preferentially signal marked text, usually underlining it. Widgets can use int Fl::compose_state
after having called Fl::compose(int&) to obtain the length in bytes of marked text that always finishes at the current insertion point. It's the widget's task to underline marked text. Widgets should also call void Fl::reset_marked_text()
when processing FL_UNFOCUS events. Optionally, widgets can also call void Fl::insertion_point_location(int x, int y, int height)
to indicate the window coordinates of the bottom of the current insertion point and the line height. This way, auxiliary windows that help choosing among alternative characters appear just below the insertion point. If widgets don't do that, auxiliary windows appear at the widget's bottom. The Fl_Input and Fl_Text_Editor widgets underline marked text. If none of this is done by a user-defined text editing widget, text input will work, but will not signal to the user what text is marked. Finally, text editing widgets should call set_flag(MAC_USE_ACCENTS_MENU);
in their constructor if they want to use the feature introduced with Mac OS 10.7 "Lion" where pressing and holding a key on the keyboard opens an accented-character menu window.
Though the current implementation returns immediately, future versions may take quite awhile, as they may pop up a window or do other user-interface things to allow characters to be selected.
|
static |
If the user moves the cursor, be sure to call Fl::compose_reset().
The next call to Fl::compose() will start out in an initial state. In particular it will not set "del" to non-zero. This call is very fast so it is ok to call it many times and in many places.
|
static |
Disables the system input methods facilities.
|
static |
|
inlinestatic |
Returns the last event that was processed.
This can be used to determine if a callback is being done in response to a keypress, mouse click, etc.
|
inlinestatic |
Returns non-zero if the Alt key is pressed.
|
inlinestatic |
Gets which particular mouse button caused the current event.
This returns garbage if the most recent event was not a FL_PUSH or FL_RELEASE event.
FL_LEFT_MOUSE | |
FL_MIDDLE_MOUSE | |
FL_RIGHT_MOUSE. |
|
inlinestatic |
Returns non-zero if mouse button 1 is currently held down.
For more details, see Fl::event_buttons().
|
inlinestatic |
Returns non-zero if button 2 is currently held down.
For more details, see Fl::event_buttons().
|
inlinestatic |
Returns non-zero if button 3 is currently held down.
For more details, see Fl::event_buttons().
|
inlinestatic |
Returns the mouse buttons state bits; if non-zero, then at least one button is pressed now.
This function returns the button state at the time of the event. During an FL_RELEASE event, the state of the released button will be 0. To find out, which button caused an FL_RELEASE event, you can use Fl::event_button() instead.
|
inlinestatic |
Returns non zero if we had a double click event.
Non-zero | if the most recent FL_PUSH or FL_KEYBOARD was a "double click". |
N-1 | for N clicks. A double click is counted if the same button is pressed again while event_is_click() is true. |
|
inlinestatic |
Manually sets the number returned by Fl::event_clicks().
This can be used to set it to zero so that later code does not think an item was double-clicked.
[in] | i | corresponds to no double-click if 0, i+1 mouse clicks otherwise |
|
inlinestatic |
During an FL_PASTE event of non-textual data, returns a pointer to the pasted data.
The returned data is an Fl_Image * when the result of Fl::event_clipboard_type() is Fl::clipboard_image.
|
inlinestatic |
Returns the type of the pasted data during an FL_PASTE event.
This type can be Fl::clipboard_plain_text or Fl::clipboard_image.
|
inlinestatic |
Returns non-zero if the FL_COMMAND key is pressed, either FL_CTRL or on OSX FL_META.
|
inlinestatic |
Returns non-zero if the Control key is pressed.
|
static |
Set a new event dispatch function.
The event dispatch function is called after native events are converted to FLTK events, but before they are handled by FLTK. If the dispatch function Fl_Event_Dispatch d
is set, it is up to the dispatch function to call Fl::handle_(int, Fl_Window*) or to ignore the event.
The dispatch function itself must return 0 if it ignored the event, or non-zero if it used the event. If you call Fl::handle_(), then this will return the correct value.
The event dispatch can be used to handle exceptions in FLTK events and callbacks before they reach the native event handler:
d | new dispatch function, or NULL |
|
inlinestatic |
Returns the current horizontal mouse scrolling associated with the FL_MOUSEWHEEL event.
Right is positive.
|
inlinestatic |
Returns the current vertical mouse scrolling associated with the FL_MOUSEWHEEL event.
Down is positive.
|
static |
Returns whether or not the mouse event is inside the given rectangle.
Returns non-zero if the current Fl::event_x() and Fl::event_y() put it inside the given arbitrary bounding box.
You should always call this rather than doing your own comparison so you are consistent about edge effects.
To find out, whether the event is inside a child widget of the current window, you can use Fl::event_inside(const Fl_Widget *).
[in] | xx,yy,ww,hh | bounding box |
|
static |
Returns whether or not the mouse event is inside a given child widget.
Returns non-zero if the current Fl::event_x() and Fl::event_y() put it inside the given child widget's bounding box.
This method can only be used to check whether the mouse event is inside a child widget of the window that handles the event, and there must not be an intermediate subwindow (i.e. the widget must not be inside a subwindow of the current window). However, it is valid if the widget is inside a nested Fl_Group.
You must not use it with the window itself as the o
argument in a window's handle() method.
o
must be within the same window that is handling the current event. Otherwise the results are undefined.You should always call this rather than doing your own comparison so you are consistent about edge effects.
[in] | o | child widget to be tested |
|
inlinestatic |
Returns non-zero if the mouse has not moved far enough and not enough time has passed since the last FL_PUSH or FL_KEYBOARD event for it to be considered a "drag" rather than a "click".
You can test this on FL_DRAG, FL_RELEASE, and FL_MOVE events.
|
inlinestatic |
Clears the value returned by Fl::event_is_click().
Useful to prevent the next click from being counted as a double-click or to make a popup menu pick an item with a single click. Don't pass non-zero to this.
|
inlinestatic |
Gets which key on the keyboard was last pushed.
The returned integer 'key code' is not necessarily a text equivalent for the keystroke. For instance: if someone presses '5' on the numeric keypad with numlock on, Fl::event_key() may return the 'key code' for this key, and NOT the character '5'. To always get the '5', use Fl::event_text() instead.
|
static |
Returns true if the given key
was held down (or pressed) during the last event.
This is constant until the next event is read from the server.
Fl::get_key(int) returns true if the given key is held down now. Under X this requires a round-trip to the server and is much slower than Fl::event_key(int).
Keys are identified by the unshifted values. FLTK defines a set of symbols that should work on most modern machines for every key on the keyboard:
On X Fl::get_key(FL_Button+n) does not work.
On WIN32 Fl::get_key(FL_KP_Enter) and Fl::event_key(FL_KP_Enter) do not work.
|
inlinestatic |
Returns the length of the text in Fl::event_text().
There will always be a nul at this position in the text. However there may be a nul before that if the keystroke translates to a nul character or you paste a nul character.
|
inlinestatic |
Returns the keycode of the last key event, regardless of the NumLock state.
If NumLock is deactivated, FLTK translates events from the numeric keypad into the corresponding arrow key events. event_key() returns the translated key code, whereas event_original_key() returns the keycode before NumLock translation.
|
inlinestatic |
Returns non-zero if the Shift key is pressed.
|
inlinestatic |
This is a bitfield of what shift states were on and what mouse buttons were held down during the most recent event.
The second version returns non-zero if any of the passed bits are turned on. The legal bits are:
X servers do not agree on shift states, and FL_NUM_LOCK, FL_META, and FL_SCROLL_LOCK may not work. The values were selected to match the XFree86 server on Linux. In addition there is a bug in the way X works so that the shift state is not correctly reported until the first event after the shift key is pressed or released.
|
inlinestatic |
Returns the text associated with the current event, including FL_PASTE or FL_DND_RELEASE events.
This can be used in response to FL_KEYUP, FL_KEYDOWN, FL_PASTE, and FL_DND_RELEASE.
When responding to FL_KEYUP/FL_KEYDOWN, use this function instead of Fl::event_key() to get the text equivalent of keystrokes suitable for inserting into strings and text widgets.
The returned string is guaranteed to be NULL terminated. However, see Fl::event_length() for the actual length of the string, in case the string itself contains NULLs that are part of the text data.
|
inlinestatic |
Returns the mouse position on the screen of the event.
To find the absolute position of an Fl_Window on the screen, use the difference between event_x_root(),event_y_root() and event_x(),event_y().
|
inlinestatic |
Returns the mouse position on the screen of the event.
To find the absolute position of an Fl_Window on the screen, use the difference between event_x_root(),event_y_root() and event_x(),event_y().
|
inlinestatic |
Gets the current Fl::focus() widget.
|
static |
Sets the widget that will receive FL_KEYBOARD events.
If you change Fl::focus(), the previous widget and all parents (that don't contain the new widget) are sent FL_UNFOCUS events. Changing the focus does not send FL_FOCUS to this or any widget, because sending FL_FOCUS is supposed to test if the widget wants the focus (by it returning non-zero from handle()).
|
static |
Returns true if the given key
is held down now.
Under X this requires a round-trip to the server and is much slower than Fl::event_key(int).
|
static |
Return where the mouse is on the screen by doing a round-trip query to the server.
You should use Fl::event_x_root() and Fl::event_y_root() if possible, but this is necessary if you are not sure if a mouse event has been processed recently (such as to position your first window). If the display is not open, this will open it.
|
static |
Handle events from the window system.
This is called from the native event dispatch after native events have been converted to FLTK notation. This function calls Fl::handle_(int, Fl_Window*) unless the user sets a dispatch function. If a user dispatch function is set, the user must make sure that Fl::handle_() is called, or the event will be ignored.
e | the event type (Fl::event_number() is not yet set) |
window | the window that caused this event |
|
static |
Handle events from the window system.
This function is called from the native event dispatch, unless the user sets another dispatch function. In that case, the user dispatch function must decide when to call Fl::handle_(int, Fl_Window*)
e | the event type (Fl::event_number() is not yet set) |
window | the window that caused this event |
|
inlinestatic |
Gets the widget that is being pushed.
|
static |
Sets the widget that is being pushed.
FL_DRAG or FL_RELEASE (and any more FL_PUSH) events will be sent to this widget.
If you change the pushed widget, the previous one and all parents (that don't contain the new widget) are sent FL_RELEASE events. Changing this does not send FL_PUSH to this or any widget, because sending FL_PUSH is supposed to test if the widget wants the mouse (by it returning non-zero from handle()).
|
static |
Removes a previously added event handler.
|
static |
Removes a previously added system event handler.
ha | The event handler function to remove |
|
static |
Tests the current event, which must be an FL_KEYBOARD or FL_SHORTCUT, against a shortcut value (described in Fl_Button).
Not to be confused with Fl_Widget::test_shortcut().
const char* const fl_eventnames[] |
This is an array of event names you can use to convert event numbers into names.
The array gets defined inline wherever your '#include <FL/names.h>' appears.
Example:
const char* const fl_fontnames[] |
This is an array of font names you can use to convert font numbers into names.
The array gets defined inline wherever your '#include <FL/names.h>' appears.
Example: