fltk.events
FLTK Event Types and Query Functions
This module provides typed event structures and functions for querying the current event state. It builds on the low-level Event enum to provide a more D-friendly interface for event handling.
Event Types:
- MouseEvent: Mouse position, button, and click information
- KeyEvent: Key code, text, and modifier state
- FocusEvent: Focus gained/lost information
- ResizeEvent: Window/widget resize information
Example:
// Query current mouse position
auto x = eventX();
auto y = eventY();
// Get current event as typed structure
auto mouse = currentMouseEvent();
writefln("Mouse at (%d, %d), button %d", mouse.x, mouse.y, mouse.button);
License
BSD-3-Clause
Copyright
Copyright © 2025 DDN (D Developer Network) Members
Types 6
structMouseEvent
Mouse event information.
Contains all relevant information about a mouse event including position, button state, and click count.
Fields
int xX coordinate relative to windowint yY coordinate relative to windowint rootXX coordinate relative to root windowint rootYY coordinate relative to root windowint buttonMouse button that triggered the event (1=left, 2=middle, 3=right)int clicksNumber of clicks (for double-click detection)uint stateModifier keys held during eventEvent eventThe event typeMethods
structKeyEvent
Keyboard event information.
Contains key code, text representation, and modifier state.
Fields
uint keyThe key codestring textText representation of the key (for printable characters)uint stateModifier keys held during eventEvent eventThe event type (KEYDOWN or KEYUP)Methods
structFocusEvent
structResizeEvent
Resize event information.
Fields
int widthNew widthint heightNew heightint oldWidthPrevious width (if available)int oldHeightPrevious height (if available)Methods
structMousePosition
Mouse position information.
Fields
int xint ystructComposeResult
Compose result information.
Fields
bool completeint bytesToDeleteFunctions 23
fn
MouseEvent currentMouseEvent() nothrow @nogcCreates a MouseEvent from the current FLTK event state.fn
int eventOriginalKey() nothrow @nogc @trustedGets the original key code before any keyboard remapping.fn
void eventSetIsClick(bool isClick) nothrow @nogc @trustedSets the click flag for the current event.fn
bool eventInsideRect(int x, int y, int w, int h) nothrow @nogc @trustedChecks if the current event is inside a rectangle.