Skip to main content

ClickableText

Function ClickableText 

Source
pub fn ClickableText<T>(
    text: T,
    modifier: Modifier,
    style: TextStyle,
    on_click: impl Fn(usize) + 'static,
) -> NodeId
where T: IntoSharedAnnotatedString,
Expand description

Displays annotated text and calls on_click with the byte offset under the pointer. Use LinkedText for URL and custom-action annotations.

ยงExample

use cranpose_ui::{text::AnnotatedString, *};

#[composable]
fn OffsetLabel() {
    ClickableText(
        AnnotatedString::from("Click a character"),
        Modifier::empty(),
        TextStyle::default(),
        |offset| println!("Byte offset: {offset}"),
    );
}