pub enum EventType {
KeyPress(Key),
KeyRelease(Key),
ButtonPress(Button),
ButtonRelease(Button),
MouseMove {
x: f64,
y: f64,
},
Wheel {
delta_x: i64,
delta_y: i64,
},
}展开描述
为了兼容不同的操作系统,当前的 EventType 选项是混合搭配的,以涵盖所有可能的事件。
变体§
KeyPress(Key)
键名对应于标准的 QWERTY 布局,并不直接对应用户实际输入的字母——要支持后者需要添加额外的布局逻辑。
KeyRelease(Key)
ButtonPress(Button)
鼠标按钮
ButtonRelease(Button)
MouseMove
以像素为单位。EventType::MouseMove{x: 0, y: 0} 对应左上角,x 向下增加,y 向右增加。
Wheel
delta_y 表示垂直滚动,delta_x 表示水平滚动。
正值对应向上或向右滚动,负值
对应向下或向左滚动。
Trait 实现§
impl Copy for EventType
impl StructuralPartialEq for EventType
自动 Trait 实现§
impl Freeze for EventType
impl RefUnwindSafe for EventType
impl Send for EventType
impl Sync for EventType
impl Unpin for EventType
impl UnsafeUnpin for EventType
impl UnwindSafe for EventType
通用实现§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
对拥有的值进行可变借用。阅读更多