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

Elements in column overlay on Windows #2702

Open
4 tasks done
ndtoan96 opened this issue Dec 19, 2024 · 0 comments
Open
4 tasks done

Elements in column overlay on Windows #2702

ndtoan96 opened this issue Dec 19, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@ndtoan96
Copy link

Is your issue REALLY a bug?

  • My issue is indeed a bug!
  • I am not crazy! I will not fill out this form just to ask a question or request a feature. Pinky promise.

Is there an existing issue for this?

  • I have searched the existing issues.

Is this issue related to iced?

  • My hardware is compatible and my graphics drivers are up-to-date.

What happened?

I try to code along with the youtube editor video. At the step to add cursor position, I notice that the text_editor element overlays the cursor_position element when the text is long. Here is the code:

use iced::{
    widget::{column, container, text, text_editor},
    Element, Theme,
};

fn main() -> iced::Result {
    iced::application("A cool editor", update, view)
        .theme(theme)
        .run()
}

struct State {
    content: text_editor::Content,
}

impl Default for State {
    fn default() -> Self {
        Self {
            content: text_editor::Content::with_text(include_str!("main.rs")),
        }
    }
}

#[derive(Debug, Clone)]
enum Message {
    Edit(text_editor::Action),
}

fn update(state: &mut State, message: Message) {
    match message {
        Message::Edit(action) => state.content.perform(action),
    }
}

fn view(state: &State) -> Element<Message> {
    let input = text_editor(&state.content).on_action(Message::Edit);
    let position = {
        let (line, column) = state.content.cursor_position();
        text(format!("{}:{}", line + 1, column + 1))
    };
    container(column![input, position]).padding(10).into()
}

fn theme(_state: &State) -> Theme {
    Theme::Dracula
}
Recording.2024-12-19.224704.mp4

What is the expected behavior?

The text_editor element should not overlay the below text element.

Version

master

Operating System

Windows

Do you have any log output?

No response

@ndtoan96 ndtoan96 added the bug Something isn't working label Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant