From f1e69f631171098f89ef0a0f40c6d139a4f1b056 Mon Sep 17 00:00:00 2001 From: Anthony Eid <56899983+Anthony-Eid@users.noreply.github.com> Date: Wed, 6 Aug 2025 23:24:37 -0400 Subject: [PATCH] gpui: Impl Default for ClickEvent (#35751) While default for ClickEvent shouldn't be used much this is helpful for other projects using gpui besides Zed. Mainly because the orphan rule prevents those projects from implementing their own default trait cc: @huacnlee Release Notes: - N/A --- crates/gpui/src/interactive.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/crates/gpui/src/interactive.rs b/crates/gpui/src/interactive.rs index 46af946e694c52c43b3838177699735e38b231a7..218ae5fcdfbb60b2dd99c8a656d95c3962edc98c 100644 --- a/crates/gpui/src/interactive.rs +++ b/crates/gpui/src/interactive.rs @@ -150,7 +150,7 @@ pub struct MouseClickEvent { } /// A click event that was generated by a keyboard button being pressed and released. -#[derive(Clone, Debug)] +#[derive(Clone, Debug, Default)] pub struct KeyboardClickEvent { /// The keyboard button that was pressed to trigger the click. pub button: KeyboardButton, @@ -168,6 +168,12 @@ pub enum ClickEvent { Keyboard(KeyboardClickEvent), } +impl Default for ClickEvent { + fn default() -> Self { + ClickEvent::Keyboard(KeyboardClickEvent::default()) + } +} + impl ClickEvent { /// Returns the modifiers that were held during the click event /// @@ -256,9 +262,10 @@ impl ClickEvent { } /// An enum representing the keyboard button that was pressed for a click event. -#[derive(Hash, PartialEq, Eq, Copy, Clone, Debug)] +#[derive(Hash, PartialEq, Eq, Copy, Clone, Debug, Default)] pub enum KeyboardButton { /// Enter key was clicked + #[default] Enter, /// Space key was clicked Space,