Ver código fonte

Improve keyboard event debug formatting

Reinis Mazeiks 3 anos atrás
pai
commit
a46ff93600
1 arquivos alterados com 13 adições e 1 exclusões
  1. 13 1
      packages/html/src/events.rs

+ 13 - 1
packages/html/src/events.rs

@@ -427,7 +427,7 @@ pub mod on {
 
     pub type KeyboardEvent = UiEvent<KeyboardData>;
     #[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
-    #[derive(Debug, Clone)]
+    #[derive(Clone)]
     pub struct KeyboardData {
         #[deprecated(
             since = "0.3.0",
@@ -553,6 +553,18 @@ pub mod on {
         }
     }
 
+    impl Debug for KeyboardData {
+        fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+            f.debug_struct("KeyboardData")
+                .field("key", &self.key())
+                .field("code", &self.code())
+                .field("modifiers", &self.modifiers())
+                .field("location", &self.location())
+                .field("is_auto_repeating", &self.is_auto_repeating())
+                .finish()
+        }
+    }
+
     pub type FocusEvent = UiEvent<FocusData>;
     #[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
     #[derive(Debug, Clone)]