added input clearing on focus

master
hheik 2023-03-21 04:16:43 +02:00
parent 75286df87c
commit 2a17262f70
1 changed files with 15 additions and 4 deletions

View File

@ -111,7 +111,10 @@ fn ui_system(
});
ui.horizontal(|ui| {
ui.set_width(INPUT_TEXT_WIDTH);
ui.text_edit_singleline(&mut ui_state.name);
let input = ui.text_edit_singleline(&mut ui_state.name);
if input.gained_focus() {
ui_state.name = String::from("");
}
});
});
ui.add_space(2.);
@ -205,12 +208,16 @@ fn ui_system(
match i {
4 => {
let value = &mut ui_state.level;
if ui.add(egui::TextEdit::singleline(value)).changed() {
let input = ui.add(egui::TextEdit::singleline(value));
if input.changed() {
*value = digit_filter(value);
if let Ok(value) = value.parse::<StatValue>() {
inspector.derived_stats.level = Some(value);
}
}
if input.gained_focus() {
*value = String::from("");
}
}
_ => (),
}
@ -310,10 +317,11 @@ fn ui_system(
ui.set_width(*width);
}
if !ui_state.derived_stats.contains_key(&stat) {
ui_state.derived_stats.insert(stat, "0".to_string());
ui_state.derived_stats.insert(stat, "".to_string());
}
let value = ui_state.derived_stats.get_mut(&stat).unwrap();
if ui.add(egui::TextEdit::singleline(value)).changed() {
let input = ui.add(egui::TextEdit::singleline(value));
if input.changed() {
*value = digit_filter(value);
if let (Ok(value), derived) = (
value.parse::<StatValue>(),
@ -322,6 +330,9 @@ fn ui_system(
*derived = Some(value);
}
}
if input.gained_focus() {
*value = String::from("");
}
});
let possible_ivs = if let (Some(pokemon), Some(level), Some(derived_stat)) = (