From 20ddb88e95b78880ae261813f3be123ac4d79ef4 Mon Sep 17 00:00:00 2001 From: richerfu <32590310+richerfu@users.noreply.github.com> Date: Sun, 12 Oct 2025 21:20:38 +0800 Subject: [PATCH] input: impl Selectable for TextInput that allow it as tigger for popover (#1353) --- crates/ui/src/input/text_input.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/crates/ui/src/input/text_input.rs b/crates/ui/src/input/text_input.rs index 31f07296..e06371b1 100644 --- a/crates/ui/src/input/text_input.rs +++ b/crates/ui/src/input/text_input.rs @@ -10,7 +10,7 @@ use crate::indicator::Indicator; use crate::input::clear_button; use crate::input::element::{LINE_NUMBER_RIGHT_MARGIN, RIGHT_MARGIN}; use crate::scroll::Scrollbar; -use crate::{h_flex, StyledExt}; +use crate::{h_flex, Selectable, StyledExt}; use crate::{v_flex, ActiveTheme}; use crate::{IconName, Size}; use crate::{Sizable, StyleSized}; @@ -32,6 +32,7 @@ pub struct TextInput { bordered: bool, focus_bordered: bool, tab_index: isize, + selected: bool, } impl Sizable for TextInput { @@ -41,6 +42,17 @@ impl Sizable for TextInput { } } +impl Selectable for TextInput { + fn selected(mut self, selected: bool) -> Self { + self.selected = selected; + self + } + + fn is_selected(&self) -> bool { + self.selected + } +} + impl TextInput { /// Create a new [`TextInput`] element bind to the [`InputState`]. pub fn new(state: &Entity) -> Self { @@ -58,6 +70,7 @@ impl TextInput { bordered: true, focus_bordered: true, tab_index: 0, + selected: false, } }