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) {
|
pub fn ui(&mut self, ui: &mut Ui) {
|
||||||
ui.add(crate::__egui_github_link_file_line!());
|
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.horizontal(|ui| {
|
||||||
ui.style_mut().spacing.item_spacing.x = 0.0;
|
ui.style_mut().spacing.item_spacing.x = 0.0;
|
||||||
ui.add(Label::new("Text can have ").text_color(srgba(110, 255, 110, 255)));
|
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,
|
desired_height_rows,
|
||||||
} = self;
|
} = 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 text_style = text_style.unwrap_or_else(|| ui.style().body_text_style);
|
||||||
let font = &ui.fonts()[text_style];
|
let font = &ui.fonts()[text_style];
|
||||||
let line_spacing = font.row_height();
|
let line_spacing = font.row_height();
|
||||||
|
@ -245,6 +234,17 @@ impl<'t> Widget for TextEdit<'t> {
|
||||||
galley.size.y.max(desired_height),
|
galley.size.y.max(desired_height),
|
||||||
);
|
);
|
||||||
let rect = ui.allocate_space(desired_size);
|
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 {
|
let sense = if enabled {
|
||||||
Sense::click_and_drag()
|
Sense::click_and_drag()
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue