Module carbide_core::event [−][src]
Contains all render used to describe the input events that Widget
s may handle.
The two primary render of this module are:
Input
: carbide's input type passed by the user toUi::handle_event
in order to drive theUi
.Event
: enumerates all possible events interpreted by carbide that may be propagated to widgets.
The Event System
carbide's event system looks like this:
Input -> Ui -> Event -> Widget
The Ui receives Inputs such as Press
and Release
via the Ui::handle_event
method.
It interprets these Inputs to create higher-level Events such as DoubleClick
,
WidgetCapturesKeyboard
, etc. These Events are stored and then fed to each Widget when
Ui::set_widgets
is called. At the end of Ui::set_widgets
the stored Events are flushed
ready for the next incoming Inputs.
carbide uses the pistoncore-input
crate's Input
type. There are a few reasons for this:
- This
Input
type already provides a number of useful variants of events that we wish to provide and handle within carbide, and we do not yet see any great need to re-write it and duplicate code. - The
Input
type is already compatible with allpistoncore-window
backends includingglfw_window
,sdl2_window
andglutin_window
. That said, co-ordinates and scroll directions may need to be translated to carbide's orientation. - The
pistoncore-input
crate also provides aGenericEvent
trait which allows us to easily provide a blanket implementation ofToRawEvent
for all event render that already implement this trait.
Because we use the pistoncore-input
Event
type, we also re-export its associated data
render (Button
, ControllerAxisArgs
, Key
, etc).
Modules
event | |
input | |
touch | Touch-related items. |
Enums
Motion |