![]() |
ImFusion C++ SDK 4.4.0
|
#include <ImFusion/GUI/EventResult.h>
Simple record intended to be used as return value of the a handleInputEvent() function to indicate how to proceed. More...
Simple record intended to be used as return value of the a handleInputEvent() function to indicate how to proceed.
Its main property is a flag whether to continue or stop the event propagation (other event systems often call this "accepted"). Furthermore, it stores additional optional members describing visual cues or elements that the GUI should show to the user as reaction to the event (e.g. mouse cursor shape, tooltip, context menu).
Since InputEvents are often propagated to a series of handlers until propagation shall stop, the EventResult offers a combine() function to conveniently combine its additional payload (mouse cursor shape, etc.). A typical usage looks like this
Public Types | |
| enum | Propagation { ContinuePropagation = 0 , StopPropagation = 1 } |
| Named enumeration used for the readable constructor. | |
Public Member Functions | |
| EventResult ()=default | |
| Creates an empty result indicating to continue event propagation. | |
| EventResult (Propagation propagation, std::optional< MouseCursorShape > cursorShape=std::nullopt, std::optional< std::string > tooltip=std::nullopt, std::optional< Menu > contextMenu=std::nullopt) | |
| Creates an EventResult indicating whether to continue event propagation an optionally a mouse cursor to use. | |
| EventResult (Propagation propagation, std::optional< Menu > contextMenu) | |
| Convenience constructor overload so that you can write EventResult(<Propagation>, <Menu>) without specifying the nullopt cursor shape and tooltip. | |
| const EventResult & | combine (EventResult other) |
| Combines two results from different event handling functions. | |
| EventResult | combined (const EventResult &other) const |
| Combines two results from different event handling functions. | |
Public Attributes | |
| bool | stopPropagation = false |
| Flag whether the event was accepted and event processing should stop. | |
| std::optional< MouseCursorShape > | cursorShape |
| Optional field to request showing a particular mouse cursor. | |
| std::optional< std::string > | tooltip |
| Optional text to show hovering next to the mouse cursor. | |
| std::optional< Menu > | contextMenu |
| An optional menu to show to the user as reaction to the event (usually populated as reaction to a ContextMenuEvent). | |
| ImFusion::GUI::EventResult::EventResult | ( | Propagation | propagation, |
| std::optional< MouseCursorShape > | cursorShape = std::nullopt, | ||
| std::optional< std::string > | tooltip = std::nullopt, | ||
| std::optional< Menu > | contextMenu = std::nullopt ) |
Creates an EventResult indicating whether to continue event propagation an optionally a mouse cursor to use.
Is implicit by design so that you can write return EventResult::StopPropagation
| const EventResult & ImFusion::GUI::EventResult::combine | ( | EventResult | other | ) |
Combines two results from different event handling functions.
The combination logic is as follows to implement the regular use case of passing input events through a hierarchy of event handlers:
| EventResult ImFusion::GUI::EventResult::combined | ( | const EventResult & | other | ) | const |
Combines two results from different event handling functions.
The combination logic is as follows to implement the regular use case of passing input events through a hierarchy of event handlers: