MouseEvent
[Event](/reference/events/event) representing mouse movement, clicks, or scroll input.
[MouseEvent](/reference/events/mouse_event)
is dispatched when the mouse moves, a button is pressed or released, or the scroll wheel is used. Nodes can handle this event by overriding the OnMouseEvent()
method. The event contains mouse position, scroll delta, button state, and event type.
cpp
class MyNode : public vglx::Node {
public:
auto OnMouseEvent(vglx::MouseEvent* event) -> void override {
if (
event->type == vglx::MouseEvent::Type::ButtonPressed &&
event->button == vglx::MouseButton::Left
) {
Select();
}
if (event->type == vglx::MouseEvent::Type::Moved) {
UpdateCursor(event->position);
}
}
};
INFO
Derives from Event and inherits all public properties and methods.
Properties
button MouseButton
cpp
MouseButton button
Mouse button involved in the event (if any).
type MouseEvent::Type
cpp
MouseEvent::Type type
Mouse event type.
Functions
GetType() EventType virtual
cpp
EventType vglx::MouseEvent::GetType() const override
Returns event type.