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

MouseArea not working with Rich text #2807

Open
4 tasks done
nick42d opened this issue Feb 18, 2025 · 0 comments
Open
4 tasks done

MouseArea not working with Rich text #2807

nick42d opened this issue Feb 18, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@nick42d
Copy link

nick42d commented Feb 18, 2025

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?

G'day,

Have noticed that MouseArea does not seem to fire off on_press messages with the Rich text widget (but works as expected with regular Text widget).

My use case is creating a clickable hyperlink - I was using Rich text to get an underline.

Possibly has some crossover with #2743.

Here's a reproducible sample (main.rs with iced 0.13.1 in Cargo.toml).

#[derive(Debug, Clone)]
enum Message {
    TextPressed,
    RichTextPressed,
}

fn main() {
    iced::run("Test", update, view).unwrap();
}

fn update(_: &mut (), message: Message) {
    match message {
        Message::TextPressed => println!("Text pressed"),
        Message::RichTextPressed => println!("Rich text pressed"),
    }
}

fn view(_: &()) -> iced::Element<Message> {
    iced::widget::row![
        iced::widget::mouse_area(iced::widget::text("Clickable text"))
            .on_press(Message::TextPressed),
        iced::widget::mouse_area(iced::widget::rich_text([iced::widget::span(
            "Clickable rich text"
        )]))
        .on_press(Message::RichTextPressed),
    ]
    .into()
}

Cheers Nick

What is the expected behavior?

Expected - MouseArea on_press events are fired when Rich text wrapped in MouseArea is pressed.

Version

crates.io release

Operating System

Linux

Do you have any log output?

@nick42d nick42d added the bug Something isn't working label Feb 18, 2025
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