Skip to main content

delete

Function delete 

Source
pub fn delete(
    edit: &mut TextEdit,
    config: &Config,
    metrics: &Metrics<'_>,
) -> bool
Expand description

Deletes the selection, or the character after the caret.

The other side of the caret from backspace; a delete at the end of the text does nothing.


let mut edit = TextEdit::new("ABCDE", &config, &metrics, true);
edit.set_caret_index(3);
assert!(ops::delete(&mut edit, &config, &metrics));
assert_eq!(edit.text, "ABCE");

edit.set_caret_index(edit.len_chars());
assert!(!ops::delete(&mut edit, &config, &metrics));
assert_eq!(edit.text, "ABCE");