diff --git a/widget/src/text_editor.rs b/widget/src/text_editor.rs index 502b5de949..f1ec589b04 100644 --- a/widget/src/text_editor.rs +++ b/widget/src/text_editor.rs @@ -110,6 +110,8 @@ pub struct TextEditor< line_height: LineHeight, width: Length, height: Length, + min_height: f32, + max_height: f32, padding: Padding, wrapping: Wrapping, class: Theme::Class<'a>, @@ -139,6 +141,8 @@ where line_height: LineHeight::default(), width: Length::Fill, height: Length::Shrink, + min_height: 0.0, + max_height: f32::INFINITY, padding: Padding::new(5.0), wrapping: Wrapping::default(), class: Theme::default(), @@ -169,15 +173,27 @@ where self } + /// Sets the width of the [`TextEditor`]. + pub fn width(mut self, width: impl Into) -> Self { + self.width = Length::from(width.into()); + self + } + /// Sets the height of the [`TextEditor`]. pub fn height(mut self, height: impl Into) -> Self { self.height = height.into(); self } - /// Sets the width of the [`TextEditor`]. - pub fn width(mut self, width: impl Into) -> Self { - self.width = Length::from(width.into()); + /// Sets the minimum height of the [`TextEditor`]. + pub fn min_height(mut self, min_height: impl Into) -> Self { + self.min_height = min_height.into().0; + self + } + + /// Sets the maximum height of the [`TextEditor`]. + pub fn max_height(mut self, max_height: impl Into) -> Self { + self.max_height = max_height.into().0; self } @@ -265,6 +281,8 @@ where line_height: self.line_height, width: self.width, height: self.height, + min_height: self.min_height, + max_height: self.max_height, padding: self.padding, wrapping: self.wrapping, class: self.class, @@ -549,7 +567,11 @@ where state.highlighter_settings = self.highlighter_settings.clone(); } - let limits = limits.width(self.width).height(self.height); + let limits = limits + .width(self.width) + .height(self.height) + .min_height(self.min_height) + .max_height(self.max_height); internal.editor.update( limits.shrink(self.padding).max(),