Skip to content

scrolling text #1413

Answered by tarkah
BKSalman asked this question in Q&A
Aug 16, 2022 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

Text wraps by default. The only way to get it to "scroll" is by using the text input. If you just want it to be cut off on a single row of text, you can make the following change:

    fn view(&mut self) -> Element<'_, Self::Message> {
        container::Container::new(
            Text::new(&self.key).height(iced::Length::Units(20))
        )
        .width(iced::Length::Fill)
        .height(iced::Length::Fill)
        .center_x()
        .into()
    }

Iced uses default font size of 20. Match the height of the Text widget with the font size so it doesn't wrap.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@BKSalman
Comment options

Answer selected by hecrj
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants