Skip to content
Snippets Groups Projects
Unverified Commit ea84d912 authored by John's avatar John Committed by GitHub
Browse files

Merge pull request #28 from MrGVSV/fix-backspace

Fixed backspace for textbox input
parents e1073be4 01042aa9
No related branches found
No related tags found
No related merge requests found
......@@ -63,7 +63,7 @@ pub fn TextBox(value: String, on_change: Option<OnChange>) {
if !cloned_has_focus.get().0 {
return;
}
if c == '\u{8}' {
if is_backspace(c) {
if current_value.len() > 0 {
current_value.truncate(current_value.len() - 1);
}
......@@ -92,3 +92,10 @@ pub fn TextBox(value: String, on_change: Option<OnChange>) {
</Background>
}
}
/// Checks if the given character contains the "Backspace" sequence
///
/// Context: [Wikipedia](https://en.wikipedia.org/wiki/Backspace#Common_use)
fn is_backspace(c: char) -> bool {
c == '\u{8}' || c == '\u{7f}'
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment