FLTK 1.3.7: Events handling functions

FLTK 1.3.7

Functions | Variables
Events handling functions

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.
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.
static int | Fl::event_ctrl ()
| Returns non-zero if the Control key is pressed.
static Fl_Event_Dispatch | Fl::event_dispatch ()
| Return the current event dispatch function.
static void | Fl::event_dispatch (Fl_Event_Dispatch d)
| Set a new event dispatch function. More...
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 (const Fl_Widget *)
| Returns whether or not the mouse event is inside a given child widget. 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_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.
static int | Fl::event_state ()
| Returns the keyboard and mouse button states of the last event. More...
static int | Fl::event_state (int mask)
| Returns non-zero if any of the passed event state bits are turned on. More...
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...

## Detailed Description

Fl class events handling API declared in <FL/Fl.H>

## Function Documentation

## ◆ add_handler()

void Fl::add_handler | ( | Fl_Event_Handler | ha | ) |
| 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:

- FL_SHORTCUT events that are not recognized by any widget. This lets you provide global shortcut keys.
- FL_SCREEN_CONFIGURATION_CHANGED events. Under X11, this event requires the libXrandr.so shared library to be loadable at run-time and the X server to implement the RandR extension.
- FL_FULLSCREEN events sent to a window that enters or leaves fullscreen mode.
- System events that FLTK does not recognize. See fl_xevent.
- Some other events when the widget FLTK selected returns zero from its handle() method. Exactly which ones may change in future versions, however.

See also
  Fl::remove_handler(Fl_Event_Handler)
  Fl::event_dispatch(Fl_Event_Dispatch d)
  Fl::handle(int, Fl_Window*)

## ◆ add_system_handler()

void Fl::add_system_handler | ( | Fl_System_Handler | ha,
|  | void * | data
| ) |  |
| 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:

- X11: XEvent
- Windows: MSG
- OS X: NSEvent

Parameters

  ha | The event handler function to register
  data | User data to include on each call

See also
  Fl::remove_system_handler(Fl_System_Handler)

## ◆ belowmouse() [1/2]

static Fl_Widget* Fl::belowmouse | ( |  | ) |
| inlinestatic

Gets the widget that is below the mouse.

See also
  belowmouse(Fl_Widget*)

## ◆ belowmouse() [2/2]

void Fl::belowmouse | ( | Fl_Widget * | o | ) |
| 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()).

## ◆ compose()

int Fl::compose | ( | int & | del | ) |
| 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.

## ◆ compose_reset()

void Fl::compose_reset | ( |  | ) |
| 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.

## ◆ disable_im()

static void Fl::disable_im | ( |  | ) |
| static

Disables the system input methods facilities.

See also
  enable_im()

## ◆ enable_im()

static void Fl::enable_im | ( |  | ) |
| static

Enables the system input methods facilities.

This is the default.

See also
  disable_im()

## ◆ event()

static int Fl::event | ( |  | ) |
| 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.

## ◆ event_button()

static int Fl::event_button | ( |  | ) |
| 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.

Return values

  FL_LEFT_MOUSE |
  FL_MIDDLE_MOUSE |
  FL_RIGHT_MOUSE. |

See also
  Fl::event_buttons()

## ◆ event_button1()

static int Fl::event_button1 | ( |  | ) |
| inlinestatic

Returns non-zero if mouse button 1 is currently held down.

For more details, see Fl::event_buttons().

## ◆ event_button2()

static int Fl::event_button2 | ( |  | ) |
| inlinestatic

Returns non-zero if button 2 is currently held down.

For more details, see Fl::event_buttons().

## ◆ event_button3()

static int Fl::event_button3 | ( |  | ) |
| inlinestatic

Returns non-zero if button 3 is currently held down.

For more details, see Fl::event_buttons().

## ◆ event_buttons()

static int 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.

Returns
  a bit mask value like { [FL_BUTTON1] | [FL_BUTTON2] | [FL_BUTTON3] }

## ◆ event_clicks() [1/2]

static int Fl::event_clicks | ( |  | ) |
| inlinestatic

Returns non zero if we had a double click event.

Return values

  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.

## ◆ event_clicks() [2/2]

static void Fl::event_clicks | ( | int | i | ) |
| 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.

Parameters

  [in] | i | corresponds to no double-click if 0, i+1 mouse clicks otherwise

See also
  int event_clicks()

## ◆ event_clipboard()

static void* Fl::event_clipboard | ( |  | ) |
| 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.

## ◆ event_clipboard_type()

static const char* Fl::event_clipboard_type | ( |  | ) |
| 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.

## ◆ event_dispatch()

void Fl::event_dispatch | ( | Fl_Event_Dispatch | d | ) |
| 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:

int myHandler(int e, Fl_Window *w) {
try {
return Fl::handle_(e, w);
} catch () {
...
}
}
main() {
Fl::event_dispatch(myHandler);
...
Fl::run();
}
Fl_Window
This widget produces an actual window.
Definition: Fl_Window.H:57
Fl::run
static int run()
As long as any windows are displayed this calls Fl::wait() repeatedly.
Definition: Fl.cxx:641
Fl::handle_
static int handle_(int, Fl_Window *)
Handle events from the window system.
Definition: Fl.cxx:1318
Fl::event_dispatch
static Fl_Event_Dispatch event_dispatch()
Return the current event dispatch function.
Definition: Fl.cxx:1273
Fl::w
static int w()
Returns the width in pixels of the main screen work area.

Parameters

  d | new dispatch function, or NULL

See also
  Fl::add_handler(Fl_Event_Handler)
  Fl::handle(int, Fl_Window*)
  Fl::handle_(int, Fl_Window*)

## ◆ event_dx()

static int Fl::event_dx | ( |  | ) |
| inlinestatic

Returns the current horizontal mouse scrolling associated with the FL_MOUSEWHEEL event.

Right is positive.

## ◆ event_dy()

static int Fl::event_dy | ( |  | ) |
| inlinestatic

Returns the current vertical mouse scrolling associated with the FL_MOUSEWHEEL event.

Down is positive.

## ◆ event_inside() [1/2]

int Fl::event_inside | ( | const Fl_Widget * | o | ) |
| 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.

Note
  The mentioned restrictions are necessary, because this method does not transform coordinates of child widgets, and thus the given widget `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.

See also
  Fl::event_inside(int, int, int, int)

Parameters

  [in] | o | child widget to be tested

Returns
  non-zero, if mouse event is inside the widget

## ◆ event_inside() [2/2]

int Fl::event_inside | ( | int | xx,
|  | int | yy,
|  | int | ww,
|  | int | hh
| ) |  |
| 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 *).

Parameters

  [in] | xx,yy,ww,hh | bounding box

Returns
  non-zero, if mouse event is inside

## ◆ event_is_click() [1/2]

static int Fl::event_is_click | ( |  | ) |
| 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.

## ◆ event_is_click() [2/2]

static void Fl::event_is_click | ( | int | i | ) |
| 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.

## ◆ event_key() [1/2]

static int Fl::event_key | ( |  | ) |
| 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.

Returns
  an integer 'key code', or 0 if the last event was not a key press or release.

See also
  int event_key(int), event_text(), compose(int&).

## ◆ event_key() [2/2]

int Fl::event_key | ( | int | key | ) |
| 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:

- All keys on the main keyboard producing a printable ASCII character use the value of that ASCII character (as though shift, ctrl, and caps lock were not on). The space bar is 32.
- All keys on the numeric keypad producing a printable ASCII character use the value of that ASCII character plus FL_KP. The highest possible value is FL_KP_Last so you can range-check to see if something is on the keypad.
- All numbered function keys use the number on the function key plus FL_F. The highest possible number is FL_F_Last, so you can range-check a value.
- Buttons on the mouse are considered keys, and use the button number (where the left button is 1) plus FL_Button.
- All other keys on the keypad have a symbol: FL_Escape, FL_BackSpace, FL_Tab, FL_Enter, FL_Print, FL_Scroll_Lock, FL_Pause, FL_Insert, FL_Home, FL_Page_Up, FL_Delete, FL_End, FL_Page_Down, FL_Left, FL_Up, FL_Right, FL_Down, FL_Iso_Key, FL_Shift_L, FL_Shift_R, FL_Control_L, FL_Control_R, FL_Caps_Lock, FL_Alt_L, FL_Alt_R, FL_Meta_L, FL_Meta_R, FL_Menu, FL_Num_Lock, FL_KP_Enter. Be careful not to confuse these with the very similar, but all-caps, symbols used by Fl::event_state().

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.

## ◆ event_length()

static int Fl::event_length | ( |  | ) |
| 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.

## ◆ event_original_key()

static int Fl::event_original_key | ( |  | ) |
| 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.

## ◆ event_state() [1/2]

static int Fl::event_state | ( |  | ) |
| inlinestatic

Returns the keyboard and mouse button states of the last event.

This is a bitfield of what shift states were on and what mouse buttons were held down during the most recent event.

The legal event state bits are:

- FL_SHIFT
- FL_CAPS_LOCK
- FL_CTRL
- FL_ALT
- FL_NUM_LOCK
- FL_META
- FL_SCROLL_LOCK
- FL_BUTTON1
- FL_BUTTON2
- FL_BUTTON3

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.

## ◆ event_state() [2/2]

static int Fl::event_state | ( | int | mask | ) |
| inlinestatic

Returns non-zero if any of the passed event state bits are turned on.

Use `mask` to pass the event states you're interested in. The legal event state bits are defined in Fl::event_state().

## ◆ event_text()

static const char* Fl::event_text | ( |  | ) |
| 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.

Returns
  A NULL terminated text string equivalent of the last keystroke.

## ◆ event_x_root()

static int Fl::event_x_root | ( |  | ) |
| 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().

## ◆ event_y_root()

static int Fl::event_y_root | ( |  | ) |
| 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().

## ◆ focus() [1/2]

static Fl_Widget* Fl::focus | ( |  | ) |
| inlinestatic

Gets the current Fl::focus() widget.

See also
  Fl::focus(Fl_Widget*)

## ◆ focus() [2/2]

void Fl::focus | ( | Fl_Widget * | o | ) |
| 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()).

See also
  Fl_Widget::take_focus()

## ◆ get_key()

int Fl::get_key | ( | int | key | ) |
| 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).

See also
  event_key(int)

## ◆ get_mouse()

static void Fl::get_mouse | ( | int & | ,
|  | 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.

## ◆ handle()

int Fl::handle | ( | int | e,
|  | Fl_Window * | window
| ) |  |
| 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.

Parameters

  e | the event type (Fl::event_number() is not yet set)
  window | the window that caused this event

Returns
  0 if the event was not handled

See also
  Fl::add_handler(Fl_Event_Handler)
  Fl::event_dispatch(Fl_Event_Dispatch)

## ◆ handle_()

int Fl::handle_ | ( | int | e,
|  | Fl_Window * | window
| ) |  |
| 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*)

Parameters

  e | the event type (Fl::event_number() is not yet set)
  window | the window that caused this event

Returns
  0 if the event was not handled

See also
  Fl::event_dispatch(Fl_Event_Dispatch)

## ◆ pushed() [1/2]

static Fl_Widget* Fl::pushed | ( |  | ) |
| inlinestatic

Gets the widget that is being pushed.

See also
  void pushed(Fl_Widget*)

## ◆ pushed() [2/2]

void Fl::pushed | ( | Fl_Widget * | o | ) |
| 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()).

## ◆ remove_handler()

void Fl::remove_handler | ( | Fl_Event_Handler | ha | ) |
| static

Removes a previously added event handler.

See also
  Fl::handle(int, Fl_Window*)

## ◆ remove_system_handler()

void Fl::remove_system_handler | ( | Fl_System_Handler | ha | ) |
| static

Removes a previously added system event handler.

Parameters

  ha | The event handler function to remove

See also
  Fl::add_system_handler(Fl_System_Handler)

## ◆ test_shortcut()

int Fl::test_shortcut | ( | Fl_Shortcut | shortcut | ) |
| 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().

Returns
  non-zero if there is a match.

## Variable Documentation

## ◆ fl_eventnames

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:

#include <FL/names.h> // array will be defined here
int MyClass::handle(int e) {
printf("Event was %s (%d)\n", fl_eventnames[e], e);
// ..resulting output might be e.g. "Event was FL_PUSH (1)"..
[..]
}
fl_eventnames
const char *const fl_eventnames[]
This is an array of event names you can use to convert event numbers into names.
Definition: names.h:43

## ◆ fl_fontnames

const char* const fl_fontnames[]

Initial value:
=
{
"FL_HELVETICA",
"FL_HELVETICA_BOLD",
"FL_HELVETICA_ITALIC",
"FL_HELVETICA_BOLD_ITALIC",
"FL_COURIER",
"FL_COURIER_BOLD",
"FL_COURIER_ITALIC",
"FL_COURIER_BOLD_ITALIC",
"FL_TIMES",
"FL_TIMES_BOLD",
"FL_TIMES_ITALIC",
"FL_TIMES_BOLD_ITALIC",
"FL_SYMBOL",
"FL_SCREEN",
"FL_SCREEN_BOLD",
"FL_ZAPF_DINGBATS",
}

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:

#include <FL/names.h> // array will be defined here
int MyClass::my_callback(Fl_Widget *w, void*) {
int fnum = w->labelfont();
// Resulting output might be e.g. "Label's font is FL_HELVETICA (0)"
printf("Label's font is %s (%d)\n", fl_fontnames[fnum], fnum);
// ..resulting output might be e.g. "Label's font is FL_HELVETICA (0)"..
[..]
}
Fl_Widget
Fl_Widget is the base class for all widgets in FLTK.
Definition: Fl_Widget.H:101
fl_fontnames
const char *const fl_fontnames[]
This is an array of font names you can use to convert font numbers into names.
Definition: names.h:95
- Copyright © 1998-2021 by Bill Spitzak and others.