IWindowListener

Receiving commands from a window.

Members

Functions

getDirtyRectangle
box2i getDirtyRectangle()
onAnimate
void onAnimate(double dt, double time)

Must be called periodically (ideally 60 times per second but this is not mandatory). time must refer to the window creation time. dt and time are expressed in seconds (not milliseconds).

onDraw
void onDraw(WindowPixelFormat pf)

An image you have to draw to, or return that nothing has changed. The location of this image is given before-hand by onResized. recomputeDirtyAreas() MUST have been called before. The pixel format cannot change over the lifetime of the window.

onKeyDown
bool onKeyDown(Key key)

Called on keyboard press. Returns: true if the event was handled.

onKeyUp
bool onKeyUp(Key up)

Called on keyboard release. Returns: true if the event was handled.

onMouseCaptureCancelled
void onMouseCaptureCancelled()

Called whenever mouse capture was canceled (ALT + TAB, SetForegroundWindow...)

onMouseClick
bool onMouseClick(int x, int y, MouseButton mb, bool isDoubleClick, MouseState mstate)

Called on mouse click. Returns: true if the event was handled.

onMouseMove
void onMouseMove(int x, int y, int dx, int dy, MouseState mstate)

Called on mouse movement (might not be within the window)

onMouseRelease
bool onMouseRelease(int x, int y, MouseButton mb, MouseState mstate)

Called on mouse button release Returns: true if the event was handled.

onMouseWheel
bool onMouseWheel(int x, int y, int wheelDeltaX, int wheelDeltaY, MouseState mstate)

Called on mouse wheel movement Returns: true if the event was handled.

onResized
ImageRef!RGBA onResized(int width, int height)

The drawing area size has changed. Always called at least once before onDraw.

recomputeDirtyAreas
void recomputeDirtyAreas()

Recompute internally what needs be done for the next onDraw. This function MUST have been called before calling onDraw and getDirtyRectangle. This method exists to allow the Window to recompute these draw lists less. And because cache invalidation was easier on user code than internally in the UI. Important: once you've called recomputeDirtyAreas() you COMMIT to redraw the corresponding area given by getDirtyRectangle(). Two calls to recomputeDirtyAreas() will not yield the same area.

Meta