events.hpp

Event handlers that use JQuery.

Todo:

Events can be further sub-divided and built up (similar to DataNode objects) so that we save only the information that we’re planning to use. This may be slightly faster (given how frequently some of these like mouse move might be used), but likely to be more compelx.

An alternative speed-up might be to save the current event somewhere in emp_i on the Javascript side, and then just request the information that we might need. This approach should be easier to implement, but since everything would be copied anyway in such as case, it might not actually be a speedup.

Functions

template<typename FUN_TYPE>
void OnDocumentReady(FUN_TYPE &&fun)

Runs the specified function when the document is finished loading and being set up.

template<typename FUN_TYPE>
void OnDocumentLoad(FUN_TYPE &&fun)

Runs the specified function when the document is finished loading.

struct Event
#include <events.hpp>

Data common to all web events.

Subclassed by KeyboardEvent, MouseEvent, WheelEvent

Public Functions

template<int ARG_ID>
inline void LoadFromArg()

Public Members

bool bubbles

Is this a bubbling event?

bool cancelable

Can the default action be prevented?

struct MouseEvent : public Event
#include <events.hpp>

Mouse-specific information about web events.

Public Functions

template<int ARG_ID>
inline void LoadFromArg()

Public Members

bool altKey

Was “ALT” key was pressed?

bool ctrlKey

Was “CTRL” key pressed?

bool metaKey

Was “META” key pressed?

bool shiftKey

Was “SHIFT” key pressed?

int button

Which mouse button was pressed? -1=none (0/1/2)

int clientX

X-mouse postion, relative to current window.

int clientY

Y-mouse postion, relative to current window.

int screenX

X-mouse position, relative to the screen.

int screenY

Y-mouse position, relative to the screen.

struct KeyboardEvent : public Event
#include <events.hpp>

Keyboard-specific information about web events.

Public Functions

template<int ARG_ID>
inline void LoadFromArg()

Public Members

bool altKey

Was “ALT” key was pressed?

bool ctrlKey

Was “CTRL” key pressed?

bool metaKey

Was “META” key pressed?

bool shiftKey

Was “SHIFT” key pressed?

int charCode

Unicode character pressed.

int keyCode

Which key was pressed on the keyboard (e.g., ‘a’ and ‘A’ are the same)

struct WheelEvent : public Event
#include <events.hpp>

Mouse-wheel-specific information about web events.

Public Functions

template<int ARG_ID>
inline void LoadFromArg()

Public Members

int deltaX

Horizontal scroll amount.

int deltaY

Vertical scroll amount.

int deltaZ

Scroll amount of a mouse wheel for the z-axis.

int deltaMode

The unit of measurements for delta values (pixels, lines or pages)