better button events
This commit is contained in:
parent
21eecc15e1
commit
04f951776d
1 changed files with 16 additions and 8 deletions
24
src/main.rs
24
src/main.rs
|
@ -70,6 +70,14 @@ fn process_text(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn button(label: &str) -> egui::Button {
|
||||||
|
egui::Button::new(label).sense(egui::Sense::click_and_drag())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn button_clicked(button: egui::Response) -> bool {
|
||||||
|
button.clicked() || button.drag_stopped()
|
||||||
|
}
|
||||||
|
|
||||||
fn ui_system(
|
fn ui_system(
|
||||||
mut contexts: EguiContexts,
|
mut contexts: EguiContexts,
|
||||||
mut input_text: ResMut<InputText>,
|
mut input_text: ResMut<InputText>,
|
||||||
|
@ -84,23 +92,23 @@ fn ui_system(
|
||||||
|
|
||||||
ui.with_layout(egui::Layout::top_down(egui::Align::Center), |ui| {
|
ui.with_layout(egui::Layout::top_down(egui::Align::Center), |ui| {
|
||||||
ui.with_layout(egui::Layout::left_to_right(egui::Align::LEFT), |ui| {
|
ui.with_layout(egui::Layout::left_to_right(egui::Align::LEFT), |ui| {
|
||||||
let sort_button = ui.button("Sort");
|
let sort_button = ui.add(button("Sort"));
|
||||||
if sort_button.clicked() {
|
if button_clicked(sort_button) {
|
||||||
needs_sort.value = true;
|
needs_sort.value = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
let strip_button = ui.button("Remove Blanks");
|
let strip_button = ui.add(button("Remove Blanks"));
|
||||||
if strip_button.clicked() {
|
if button_clicked(strip_button) {
|
||||||
needs_strip.value = true;
|
needs_strip.value = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
let copy_button = ui.button("Copy");
|
let copy_button = ui.add(button("Copy"));
|
||||||
if copy_button.clicked() {
|
if button_clicked(copy_button) {
|
||||||
ui.output_mut(|o| o.copied_text = input_text.value.clone());
|
ui.output_mut(|o| o.copied_text = input_text.value.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
let clear_button = ui.button("Clear");
|
let clear_button = ui.add(button("Clear"));
|
||||||
if clear_button.clicked() {
|
if button_clicked(clear_button) {
|
||||||
input_text.value = "".to_string();
|
input_text.value = "".to_string();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue