User Interface Events
// Generates user interface events. Predefined user interface controls are not provided, Use UIEvents with
// visual overlay components to build custom user interface elements.
class RVAPI UIEvents
{
public:
// Generated event.
enum class Event
{
// No event
NONE,
// Mouse down event
MOUSEDOWN,
// Mouse up event.
MOUSEUP,
// Single mouse click event.
SINGLECLICK,
// Double mouse click event.
DOUBLECLICK,
// Triple click event.
TRIPLECLICK,
// Wheel scroll up.
WHEELUP,
// Wheel scroll down.
WHEELDOWN,
// Start drag.
STARTDRAG,
// Dragging.
DRAG,
// End drag.
ENDDRAG,
// Drop event.
DROP,
// Key input event.
KEY,
// Character input event.
CHAR,
// Window resize event.
RESIZE,
// Window close event.
CLOSE
};
// Input state.
enum class State
{
// Disabled state.
DISABLED,
// Normal state.
NORMAL,
// Hovered state.
HOVERED,
// Highlighted state.
HIGHLIGHTED,
// Clicked state.
CLICKED,
// Static state.
STATIC
};
// Control attributes.
enum Attribs
{
// Accept wheel events.
WHEEL = 1,
// Can drag.
DRAGGABLE = 2,
// Does not get events.
STATIC = 4
};
// Check if state change.
bool IsStateChange() const;
// Check if selected.
bool IsSelected() const;
// Check if disabled.
bool IsDisabled() const;
// Get character from character event.
wchar GetChar() const;
// Get mouse click position.
S2i GetMseClickPos() const;
// Get state.
State GetState() const;
// Get state color.
Color GetStateColor() const;
// Get focused host entity.
Event GetEvent() const;
// Get focused host entity.
static EntKey GetFocused();
// Get clicked host entity.
static EntKey GetClicked();
// Get dragged host entity.
static EntKey GetDragged();
// Get dropped host entity.
static EntKey GetDropped();
// Update events inside parent rectangle.
Event Update(const B2i &pRect);
// Set disabled.
void SetDisabled(bool disabled = true);
// Set selected.
void SetSelected(bool selected = true);
// Set this events object to receive keyboard events.
void SetFocus();
// Clear keyboard focus.
static void ClearFocus();
// Clear all pending events.
static void ClearEvents();
// Internal.
void *operator () () const { return (void *)wobj; }
// Construct UI events object. [host] is the entity that contains this element. [stateColors]
// allows overriding the color multiplier used for shading element state, or pass 0 for the defaults.
// [attribs] is a combination of the attribs flags or 0. [maxClicks] is the maximum number of
// mouse clicks the element will wait for. Default is 1.
UIEvents(EntKey host, Color *stateColors = 0, uint attribs = 0, uint maxClicks = 1);
// Destructor.
~UIEvents();
private:
byte wobj[128];
};