Kaynağa Gözat

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

darkfi 2 yıl önce
ebeveyn
işleme
35bd4fc24c
2 değiştirilmiş dosya ile 8 ekleme ve 1 silme
  1. 1 1
      bin/darkwallet/src/app.rs
  2. 7 0
      bin/darkwallet/src/ui/editbox.rs

+ 1 - 1
bin/darkwallet/src/app.rs

@@ -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(

+ 7 - 0
bin/darkwallet/src/ui/editbox.rs

@@ -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;
         }