# Introduce \`InteractiveText\` \(\#3397\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/510320bb477364c4e032faae0655c2cd50e47023)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 510320bb477364c4e032faae0655c2cd50e47023

Requested commit: 510320bb477364c4e032faae0655c2cd50e47023

Commit: 510320bb477364c4e032faae0655c2cd50e47023

Tree: 34db6e8bf325d5ff6c2caf420fa3865ad1aa77b1

Author: Antonio Scandurra

Committer: GitHub

## Message

````
Introduce `InteractiveText` (#3397)

This new element will let us react to click events on arbitrary ranges
of some rendered text, e.g.:

```rs
InteractiveText::new(
    "element-id",
    StyledText::new("Hello world, how is it going?").with_runs(vec![
        cx.text_style().to_run(6),
        TextRun {
            background_color: Some(green()),
            ..cx.text_style().to_run(5)
        },
        cx.text_style().to_run(18),
    ]),
)
.on_click(vec![2..4, 1..3, 7..9], |range_ix, cx| {
    println!("Clicked range {range_ix}");
})
```

As part of this, I also added the ability to give text runs a background
color.

Release Notes:

- N/A
````

## Parents

- [df7b89b6cbe65537f9b564a5694e79d1f159b6a1](https://git.cafe/gitcafe/zed/commit/df7b89b6cbe65537f9b564a5694e79d1f159b6a1?format=markdown)

- [7eeb8078f633b50dcdf60ce4c815cf90a1f46d49](https://git.cafe/gitcafe/zed/commit/7eeb8078f633b50dcdf60ce4c815cf90a1f46d49?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/510320bb477364c4e032faae0655c2cd50e47023?format=markdown)
