Derive Hash for KeyboardShortcut and Modifiers (#2563)

This commit is contained in:
Ales Tsurko 2023-01-23 12:06:54 +03:00 committed by GitHub
parent ce5472633d
commit f87c6cbd7c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -314,7 +314,7 @@ pub const NUM_POINTER_BUTTONS: usize = 5;
/// NOTE: For cross-platform uses, ALT+SHIFT is a bad combination of modifiers /// NOTE: For cross-platform uses, ALT+SHIFT is a bad combination of modifiers
/// as on mac that is how you type special characters, /// as on mac that is how you type special characters,
/// so those key presses are usually not reported to egui. /// so those key presses are usually not reported to egui.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] #[derive(Clone, Copy, Debug, Default, Hash, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub struct Modifiers { pub struct Modifiers {
/// Either of the alt keys are down (option ⌥ on Mac). /// Either of the alt keys are down (option ⌥ on Mac).
@ -777,7 +777,7 @@ impl Key {
/// ///
/// Can be used with [`crate::InputState::consume_shortcut`] /// Can be used with [`crate::InputState::consume_shortcut`]
/// and [`crate::Context::format_shortcut`]. /// and [`crate::Context::format_shortcut`].
#[derive(Clone, Copy, Debug, PartialEq, Eq)] #[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)]
pub struct KeyboardShortcut { pub struct KeyboardShortcut {
pub modifiers: Modifiers, pub modifiers: Modifiers,
pub key: Key, pub key: Key,