wallet: editbox dont draw selected when start == end, and unfocus event will unset selection

This commit is contained in:
darkfi
2024-07-08 12:49:13 +02:00
parent baf83715e6
commit 35bd4fc24c
2 changed files with 8 additions and 1 deletions

View File

@@ -360,7 +360,7 @@ impl App {
prop.set_null(0).unwrap();
prop.set_null(1).unwrap();
node.set_property_u32("z_index", 1).unwrap();
node.set_property_bool("debug", true).unwrap();
//node.set_property_bool("debug", true).unwrap();
drop(sg);
let pimpl = EditBox::new(

View File

@@ -381,6 +381,11 @@ impl EditBox {
let start = self.selected.get_u32(0)? as usize;
let end = self.selected.get_u32(1)? as usize;
// Selection started but nothing selected yet so do nothing
if start == end {
return Ok(())
}
let sel_start = std::cmp::min(start, end);
let sel_end = std::cmp::max(start, end);
@@ -627,6 +632,8 @@ impl EditBox {
} else if self.is_focused.get() {
debug!(target: "ui::editbox", "EditBox unfocused");
self.is_focused.set(false);
self.selected.set_null(0).unwrap();
self.selected.set_null(1).unwrap();
focus_changed = true;
}