input: impl Selectable for TextInput that allow it as tigger for popover (#1353)

This commit is contained in:
richerfu 2025-10-12 21:20:38 +08:00 committed by GitHub
parent bfe99a2d33
commit 20ddb88e95
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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<InputState>) -> Self {
@ -58,6 +70,7 @@ impl TextInput {
bordered: true,
focus_bordered: true,
tab_index: 0,
selected: false,
}
}