cacao/appkit/events.rs

42 lines
1.1 KiB
Rust
Raw Normal View History

2020-02-28 13:34:34 +11:00
//! Hoists some type definitions in a way that I personally find cleaner than what's in the Servo
//! code.
use crate::foundation::NSUInteger;
2020-02-28 13:34:34 +11:00
#[derive(Clone, Copy, Debug)]
pub enum EventModifierFlag {
CapsLock,
Control,
Option,
Command,
DeviceIndependentFlagsMask
}
2020-02-28 13:34:34 +11:00
impl From<EventModifierFlag> for NSUInteger {
fn from(flag: EventModifierFlag) -> NSUInteger {
match flag {
EventModifierFlag::CapsLock => 1 << 16,
EventModifierFlag::Control => 1 << 18,
EventModifierFlag::Option => 1 << 19,
EventModifierFlag::Command => 1 << 20,
EventModifierFlag::DeviceIndependentFlagsMask => 0xffff0000
}
}
}
2020-02-28 13:34:34 +11:00
impl From<&EventModifierFlag> for NSUInteger {
fn from(flag: &EventModifierFlag) -> NSUInteger {
match flag {
EventModifierFlag::CapsLock => 1 << 16,
EventModifierFlag::Control => 1 << 18,
EventModifierFlag::Option => 1 << 19,
EventModifierFlag::Command => 1 << 20,
EventModifierFlag::DeviceIndependentFlagsMask => 0xffff0000
}
}
2020-02-28 13:34:34 +11:00
}
pub enum EventType {
KeyDown
2020-02-28 13:34:34 +11:00
}