Fix: id clash for TextEdit
This commit is contained in:
parent
0832ebbf1f
commit
7e9b5de250
2 changed files with 14 additions and 11 deletions
|
@ -48,6 +48,9 @@ impl Widgets {
|
|||
pub fn ui(&mut self, ui: &mut Ui) {
|
||||
ui.add(crate::__egui_github_link_file_line!());
|
||||
|
||||
ui.checkbox(&mut self.button_enabled, "Use Cloud for training");
|
||||
ui.text_edit_singleline(&mut self.single_line_text_input);
|
||||
|
||||
ui.horizontal(|ui| {
|
||||
ui.style_mut().spacing.item_spacing.x = 0.0;
|
||||
ui.add(Label::new("Text can have ").text_color(srgba(110, 255, 110, 255)));
|
||||
|
|
|
@ -217,17 +217,6 @@ impl<'t> Widget for TextEdit<'t> {
|
|||
desired_height_rows,
|
||||
} = self;
|
||||
|
||||
let id = id.unwrap_or_else(|| {
|
||||
if let Some(id_source) = id_source {
|
||||
ui.make_persistent_id(id_source)
|
||||
} else {
|
||||
// Since we are only storing cursor, perfect persistence Id not super important
|
||||
ui.make_position_id()
|
||||
}
|
||||
});
|
||||
|
||||
let mut state = ui.memory().text_edit.get(&id).cloned().unwrap_or_default();
|
||||
|
||||
let text_style = text_style.unwrap_or_else(|| ui.style().body_text_style);
|
||||
let font = &ui.fonts()[text_style];
|
||||
let line_spacing = font.row_height();
|
||||
|
@ -245,6 +234,17 @@ impl<'t> Widget for TextEdit<'t> {
|
|||
galley.size.y.max(desired_height),
|
||||
);
|
||||
let rect = ui.allocate_space(desired_size);
|
||||
|
||||
let id = id.unwrap_or_else(|| {
|
||||
if let Some(id_source) = id_source {
|
||||
ui.make_persistent_id(id_source)
|
||||
} else {
|
||||
// Since we are only storing cursor, perfect persistence Id not super important
|
||||
ui.make_position_id() // Must be after allocate_space!
|
||||
}
|
||||
});
|
||||
let mut state = ui.memory().text_edit.get(&id).cloned().unwrap_or_default();
|
||||
|
||||
let sense = if enabled {
|
||||
Sense::click_and_drag()
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue