1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#[cfg(feature = "raw_input")]
use crate::raw_input;
use crate::{device::*, geometry::*, ime::*, window::Window};
use std::path::Path;
/// Trait that must implements for handling events.
pub trait EventHandler {
/// This is called when there are no events.
///
/// only passed `RunType::Idle` to `Context::run`.
fn idle(&mut self) {}
/// This is called at the beginning of a frame.
///
/// only passed `RunType::Idle` to `Context::run`.
fn begin_frame(&mut self) {}
/// This is called at the end of a frame.
///
/// only passed `RunType::Idle` to `Context::run`.
fn end_frame(&mut self) {}
/// This is called when the window needs redrawing.
fn draw(&mut self, _: &Window) {}
/// This is called when the window has been activated.
fn activated(&mut self, _: &Window) {}
/// This is called when the window has been inactivated.
fn inactivated(&mut self, _: &Window) {}
/// This is called when the window has been closed.
fn closed(&mut self, _: &Window) {}
/// This is called when the window has been moved.
fn moved(&mut self, _: &Window, _: ScreenPosition) {}
/// This is called when the window is resizing.
fn resizing(&mut self, _: &Window, _: PhysicalSize<u32>) {}
/// This is called when the window has been resized.
fn resized(&mut self, _: &Window, _: PhysicalSize<u32>) {}
/// This is called when the window's DPI has been changed.
fn dpi_changed(&mut self, _: &Window) {}
/// This is called when the mouse button has been pressed and released on the window.
fn mouse_input(&mut self, _: &Window, _: MouseButton, _: KeyState, _: MouseState) {}
/// This is called when the cursor has been moved on the window.
fn cursor_moved(&mut self, _: &Window, _: MouseState) {}
/// This is called when the cursor has been entered the window.
fn cursor_entered(&mut self, _: &Window, _: MouseState) {}
/// This is called when the cursor has been leaved the window.
fn cursor_leaved(&mut self, _: &Window, _: MouseState) {}
/// This is called when the keyboard key has been pressed and released.
fn key_input(&mut self, _: &Window, _: KeyCode, _: KeyState, _: bool) {}
/// This is called when the keyboard key has been inputed the character.
fn char_input(&mut self, _: &Window, _: char) {}
/// This is called when the IME starts composition.
fn ime_start_composition(&mut self, _: &Window) {}
/// This is called when the IME composition status has been changed.
fn ime_composition(&mut self, _: &Window, _: &Composition, _: Option<&CandidateList>) {}
/// This is called when the IME ends composition.
fn ime_end_composition(&mut self, _: &Window, _: Option<&str>) {}
/// This is called when files have been dropped on the window.
fn drop_files(&mut self, _: &Window, _: &[&Path], _: PhysicalPosition<f32>) {}
/// This is called when raw data has been inputed.
#[cfg(feature = "raw_input")]
fn raw_input(&mut self, _: &Window, _: &raw_input::InputData) {}
/// This is called when a device state has been changead.
#[cfg(feature = "raw_input")]
fn raw_input_device_change(
&mut self,
_: &Window,
_: &raw_input::Device,
_: raw_input::DeviceChangeState,
) {
}
}