diff options
author | 2022-03-18 22:22:19 +0700 | |
---|---|---|
committer | 2022-03-18 22:22:19 +0700 | |
commit | 497a3ca8abb99f2bf25083a51388146433fe90a9 (patch) | |
tree | 7c7f54afeaf2d070b9e5b017ea114f8d4208b2d1 | |
parent | 32fd8dadda6636b11d4a1d9f59b467e57b3706a8 (diff) | |
download | iced-497a3ca8abb99f2bf25083a51388146433fe90a9.tar.gz iced-497a3ca8abb99f2bf25083a51388146433fe90a9.tar.bz2 iced-497a3ca8abb99f2bf25083a51388146433fe90a9.zip |
Restore `TextInput::draw` helper
This helper should be unnecessary in the future.
-rw-r--r-- | native/src/widget/text_input.rs | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/native/src/widget/text_input.rs b/native/src/widget/text_input.rs index d13d6ef1..057f34c6 100644 --- a/native/src/widget/text_input.rs +++ b/native/src/widget/text_input.rs @@ -154,6 +154,29 @@ where pub fn state(&self) -> &State { self.state } + + /// Draws the [`TextInput`] with the given [`Renderer`], overriding its + /// [`Value`] if provided. + pub fn draw( + &self, + renderer: &mut Renderer, + layout: Layout<'_>, + cursor_position: Point, + value: Option<&Value>, + ) { + draw( + renderer, + layout, + cursor_position, + &self.state, + value.unwrap_or(&self.value), + &self.placeholder, + self.size, + &self.font, + self.is_secure, + self.style_sheet.as_ref(), + ) + } } /// Computes the layout of a [`TextInput`]. @@ -791,18 +814,7 @@ where cursor_position: Point, _viewport: &Rectangle, ) { - draw( - renderer, - layout, - cursor_position, - &self.state, - &self.value, - &self.placeholder, - self.size, - &self.font, - self.is_secure, - self.style_sheet.as_ref(), - ) + self.draw(renderer, layout, cursor_position, None) } } |