From ac1d98aa9b8b0bb0cf3bd6a3b89406d003403bfe Mon Sep 17 00:00:00 2001 From: Samson Date: Sun, 21 Jul 2024 09:29:24 -0500 Subject: feat: add width setter --- widget/src/text_editor.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'widget') diff --git a/widget/src/text_editor.rs b/widget/src/text_editor.rs index e0102656..0029bc87 100644 --- a/widget/src/text_editor.rs +++ b/widget/src/text_editor.rs @@ -109,6 +109,12 @@ where self } + /// Sets the width of the [`TextEditor`]. + pub fn width(mut self, width: impl Into) -> Self { + self.width = width.into(); + self + } + /// Sets the message that should be produced when some action is performed in /// the [`TextEditor`]. /// -- cgit From 4081e2b19257378ef6c454f2e3abe57f25a2f088 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Fri, 13 Sep 2024 01:08:23 +0200 Subject: Take `Into` in `TextEditor::width` Since a `Shrink` width would not make sense. --- widget/src/text_editor.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'widget') diff --git a/widget/src/text_editor.rs b/widget/src/text_editor.rs index 0029bc87..7e2a30f1 100644 --- a/widget/src/text_editor.rs +++ b/widget/src/text_editor.rs @@ -110,8 +110,8 @@ where } /// Sets the width of the [`TextEditor`]. - pub fn width(mut self, width: impl Into) -> Self { - self.width = width.into(); + pub fn width(mut self, width: impl Into) -> Self { + self.width = Length::from(width.into()); self } -- cgit From 7c7e94c8d1f9b843ab6d828f0976becbb447ba6e Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Fri, 13 Sep 2024 01:10:36 +0200 Subject: Set `Limits::width` in `TextEditor` layout --- widget/src/text_editor.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'widget') diff --git a/widget/src/text_editor.rs b/widget/src/text_editor.rs index 7e2a30f1..5b565c39 100644 --- a/widget/src/text_editor.rs +++ b/widget/src/text_editor.rs @@ -504,7 +504,7 @@ where state.highlighter_settings = self.highlighter_settings.clone(); } - let limits = limits.height(self.height); + let limits = limits.width(self.width).height(self.height); internal.editor.update( limits.shrink(self.padding).max(), -- cgit