Skip to content

Commit

Permalink
debug_ui: Add possibility to edit HTML text in EditText
Browse files Browse the repository at this point in the history
  • Loading branch information
kjarosh committed Nov 8, 2024
1 parent b608792 commit e79fb91
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions core/src/debug_ui/display_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ pub struct DisplayObjectWindow {
hovered_debug_rect: Option<DisplayObjectHandle>,
hovered_bounds: Option<Rectangle<Twips>>,
search: String,

/// A buffer for editing EditText
html_text: String,
}

impl Default for DisplayObjectWindow {
Expand All @@ -89,6 +92,7 @@ impl Default for DisplayObjectWindow {
hovered_debug_rect: None,
hovered_bounds: None,
search: Default::default(),
html_text: Default::default(),
}
}
}
Expand Down Expand Up @@ -554,6 +558,26 @@ impl DisplayObjectWindow {
}
});
});

let html_text_response = CollapsingHeader::new("HTML Text")
.id_salt(ui.id().with("html-text"))
.show(ui, |ui| {
ui.add_sized(
ui.available_size(),
TextEdit::multiline(&mut self.html_text),
);
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
if ui.button("Set").clicked() {
object.set_html_text(&WString::from_utf8(&self.html_text), context);
}
if ui.button("Reset").clicked() {
self.html_text = object.html_text().to_string();
}
});
});
if html_text_response.fully_closed() {
self.html_text = object.html_text().to_string();
}
}

pub fn show_avm2_button<'gc>(
Expand Down

0 comments on commit e79fb91

Please sign in to comment.