Add protocol name to sandbox

This commit is contained in:
mars 2022-11-16 19:19:41 -07:00
parent 0b8ce299b5
commit 4e9b01810a
1 changed files with 7 additions and 1 deletions

View File

@ -31,6 +31,7 @@ struct App {
panels: Vec<PanelWindow>,
next_idx: usize,
last_update: Instant,
protocol_buf: String,
bind_message_buf: String,
}
@ -46,6 +47,7 @@ impl App {
panels: vec![],
next_idx: 0,
last_update: Instant::now(),
protocol_buf: String::new(),
bind_message_buf: String::new(),
}
}
@ -56,12 +58,16 @@ impl eframe::App for App {
ctx.request_repaint();
egui::SidePanel::left("left_panel").show(ctx, |ui| {
ui.label("Protocol name:");
ui.text_edit_singleline(&mut self.protocol_buf);
ui.label("Bind message:");
let text_edit = egui::TextEdit::multiline(&mut self.bind_message_buf).code_editor();
ui.add(text_edit);
if ui.button("Bind Panel").clicked() {
let msg = self.bind_message_buf.as_bytes().to_vec();
let panel = self.script.create_panel(msg).unwrap();
let panel = self.script.create_panel(&self.protocol_buf, msg).unwrap();
let index = self.next_idx;
self.next_idx += 1;