Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add width setter for Text-Editor widget #2513

Merged
merged 3 commits into from
Sep 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion widget/src/text_editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ where
self
}

/// Sets the width of the [`TextEditor`].
pub fn width(mut self, width: impl Into<Pixels>) -> Self {
self.width = Length::from(width.into());
self
}

/// Sets the message that should be produced when some action is performed in
/// the [`TextEditor`].
///
Expand Down Expand Up @@ -498,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(),
Expand Down
Loading