summaryrefslogtreecommitdiffstats
path: root/widget/src/text_input.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2023-09-10 03:36:31 +0200
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2023-09-10 03:36:31 +0200
commitbc1bde0d5ca1ec291f13e108f1543daa75b97848 (patch)
tree7d428814f6077e4af9ca0a92c936840e3eaf8e77 /widget/src/text_input.rs
parent6d379b7fcef817bee1b1cb367bd308f9c6655b0b (diff)
downloadiced-bc1bde0d5ca1ec291f13e108f1543daa75b97848.tar.gz
iced-bc1bde0d5ca1ec291f13e108f1543daa75b97848.tar.bz2
iced-bc1bde0d5ca1ec291f13e108f1543daa75b97848.zip
Fix `ComboBox` widget not displaying selection text
Diffstat (limited to 'widget/src/text_input.rs')
-rw-r--r--widget/src/text_input.rs28
1 files changed, 27 insertions, 1 deletions
diff --git a/widget/src/text_input.rs b/widget/src/text_input.rs
index bfd196fd..7d5ae806 100644
--- a/widget/src/text_input.rs
+++ b/widget/src/text_input.rs
@@ -200,6 +200,32 @@ where
self
}
+ /// Lays out the [`TextInput`], overriding its [`Value`] if provided.
+ ///
+ /// [`Renderer`]: text::Renderer
+ pub fn layout(
+ &self,
+ tree: &mut Tree,
+ renderer: &Renderer,
+ limits: &layout::Limits,
+ value: Option<&Value>,
+ ) -> layout::Node {
+ layout(
+ renderer,
+ limits,
+ self.width,
+ self.padding,
+ self.size,
+ self.font,
+ self.line_height,
+ self.icon.as_ref(),
+ tree.state.downcast_mut::<State<Renderer::Paragraph>>(),
+ value.unwrap_or(&self.value),
+ &self.placeholder,
+ self.is_secure,
+ )
+ }
+
/// Draws the [`TextInput`] with the given [`Renderer`], overriding its
/// [`Value`] if provided.
///
@@ -1411,7 +1437,7 @@ fn find_cursor_position<P: text::Paragraph>(
Some(
unicode_segmentation::UnicodeSegmentation::graphemes(
- &value[..char_offset],
+ &value[..char_offset.min(value.len())],
true,
)
.count(),