Commit 4fc7608e authored by William's avatar William

Add "Delete" key to Textbox

parent 1474ea1c
Pipeline #3685 passed with stages
in 8 minutes and 40 seconds
......@@ -158,6 +158,7 @@ impl Backend for OrbitalBackend {
let key = {
match key_event.scancode {
orbclient::K_BKSP => Key::Backspace,
orbclient::K_DEL => Key::Delete,
orbclient::K_UP => Key::Up,
orbclient::K_DOWN => Key::Down,
orbclient::K_LEFT => Key::Left,
......
......@@ -7,6 +7,7 @@ use crate::{Event, EventBox, EventHandler, Widget};
pub enum Key {
Unknown,
Backspace,
Delete,
Up,
Down,
Left,
......
......@@ -58,6 +58,17 @@ impl TextBoxState {
}
}
}
Key::Delete => {
let len = self.text.borrow().len();
if len > 0 {
if self.selection_start.get() < len {
for _ in 0..(self.selection_length.get() + 1) {
(*self.text.borrow_mut()).remove(self.selection_start.get());
}
self.update_selection_start(self.selection_start.get() as i32);
}
}
}
_ => {}
},
}
......@@ -116,7 +127,6 @@ impl State for TextBoxState {
{
let scroll_viewer = context.child_by_id("scroll_viewer");
if let Some(bounds) = scroll_viewer.unwrap().try_get_mut::<Bounds>() {
scroll_viewer_width = bounds.width();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment