pub enum Event {
Show 22 variants
Closed,
Resized {
width: u32,
height: u32,
},
LostFocus,
GainedFocus,
TextEntered {
unicode: char,
},
KeyPressed {
code: Key,
alt: bool,
ctrl: bool,
shift: bool,
system: bool,
},
KeyReleased {
code: Key,
alt: bool,
ctrl: bool,
shift: bool,
system: bool,
},
MouseWheelScrolled {
wheel: MouseWheel,
delta: f32,
x: i32,
y: i32,
},
MouseButtonPressed {
button: MouseButton,
x: i32,
y: i32,
},
MouseButtonReleased {
button: MouseButton,
x: i32,
y: i32,
},
MouseMoved {
x: i32,
y: i32,
},
MouseEntered,
MouseLeft,
JoystickButtonPressed {
joystickid: u32,
button: u32,
},
JoystickButtonReleased {
joystickid: u32,
button: u32,
},
JoystickMoved {
joystickid: u32,
axis: Axis,
position: f32,
},
JoystickConnected {
joystickid: u32,
},
JoystickDisconnected {
joystickid: u32,
},
TouchBegan {
finger: u32,
x: i32,
y: i32,
},
TouchMoved {
finger: u32,
x: i32,
y: i32,
},
TouchEnded {
finger: u32,
x: i32,
y: i32,
},
SensorChanged {
type_: sfSensorType,
x: f32,
y: f32,
z: f32,
},
// some variants omitted
}
Expand description
Defines a system event and its parameters.
Event
holds all the informations about a system event that just happened.
Events are retrieved using the
Window::poll_event
or Window::wait_event
functions.
An Event
instance contains the type of the event
(mouse moved, key pressed, window closed, …) as well as the details about this
particular event.
Usage example
while let Some(event) = window.poll_event() {
match event {
Event::Closed | Event::KeyPressed { code: Key::Escape, .. } => window.close(),
Event::Resized { width, height } => do_something_with_the_new_size(width, height),
_ => { /* Do nothing */ }
}
}
Variants§
Closed
The window requested to be closed
Resized
The window was resized
LostFocus
The window lost the focus
GainedFocus
The window gained the focus
TextEntered
A character was entered
KeyPressed
Fields
A key was pressed
KeyReleased
Fields
A key was released
MouseWheelScrolled
Fields
wheel: MouseWheel
Which wheel (for mice with multiple ones).
The mouse wheel was scrolled
MouseButtonPressed
Fields
Code of the button that has been pressed.
A mouse button was pressed
MouseButtonReleased
Fields
Code of the button that has been pressed.
A mouse button was released
MouseMoved
Fields
The mouse cursor moved
MouseEntered
The mouse cursor entered the area of the window
MouseLeft
The mouse cursor left the area of the window
JoystickButtonPressed
Fields
Index of the button that has been pressed (in range [0 .. Joystick::button_count - 1])
A joystick button was pressed
JoystickButtonReleased
Fields
Index of the button that has been pressed (in range [0 .. Joystick::button_count - 1])
A joystick button was released
JoystickMoved
Fields
The joystick moved along an axis
JoystickConnected
A joystick was connected
JoystickDisconnected
A joystick was disconnected
TouchBegan
Fields
A touch event began
TouchMoved
Fields
A touch moved
TouchEnded
Fields
A touch event ended
SensorChanged
Fields
type_: sfSensorType
Type of the sensor.
A sensor value changed