Input backspace

This commit is contained in:
RainBus
2024-10-17 23:13:41 +08:00
parent c8eb942b13
commit c79e17a06f

View File

@@ -48,9 +48,20 @@ impl Component for InputComponent {
self.cursor += 1;
}
(Backspace, &KeyModifiers::NONE) => {
if self.value.pop().is_some() {
if self.cursor > 0 {
self.value.remove(self.cursor - 1);
self.cursor -= 1;
};
}
}
(Left, &KeyModifiers::NONE) => {
if self.cursor > 0 {
self.cursor -= 1;
}
}
(Right, &KeyModifiers::NONE) => {
if self.cursor < self.value.len() {
self.cursor += 1;
}
}
_ => {}
}