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
This commit is contained in:
commit
510320bb47
11 changed files with 262 additions and 33 deletions
|
@ -9423,6 +9423,7 @@ impl Render for Editor {
|
|||
font_weight: FontWeight::NORMAL,
|
||||
font_style: FontStyle::Normal,
|
||||
line_height: relative(1.).into(),
|
||||
background_color: None,
|
||||
underline: None,
|
||||
white_space: WhiteSpace::Normal,
|
||||
},
|
||||
|
@ -9437,6 +9438,7 @@ impl Render for Editor {
|
|||
font_weight: FontWeight::NORMAL,
|
||||
font_style: FontStyle::Normal,
|
||||
line_height: relative(settings.buffer_line_height.value()),
|
||||
background_color: None,
|
||||
underline: None,
|
||||
white_space: WhiteSpace::Normal,
|
||||
},
|
||||
|
|
|
@ -2452,7 +2452,7 @@ impl LineWithInvisibles {
|
|||
len: line_chunk.len(),
|
||||
font: text_style.font(),
|
||||
color: text_style.color,
|
||||
background_color: None,
|
||||
background_color: text_style.background_color,
|
||||
underline: text_style.underline,
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue