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(
|
||||
mut contexts: EguiContexts,
|
||||
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::left_to_right(egui::Align::LEFT), |ui| {
|
||||
let sort_button = ui.button("Sort");
|
||||
if sort_button.clicked() {
|
||||
let sort_button = ui.add(button("Sort"));
|
||||
if button_clicked(sort_button) {
|
||||
needs_sort.value = true;
|
||||
}
|
||||
|
||||
let strip_button = ui.button("Remove Blanks");
|
||||
if strip_button.clicked() {
|
||||
let strip_button = ui.add(button("Remove Blanks"));
|
||||
if button_clicked(strip_button) {
|
||||
needs_strip.value = true;
|
||||
}
|
||||
|
||||
let copy_button = ui.button("Copy");
|
||||
if copy_button.clicked() {
|
||||
let copy_button = ui.add(button("Copy"));
|
||||
if button_clicked(copy_button) {
|
||||
ui.output_mut(|o| o.copied_text = input_text.value.clone());
|
||||
}
|
||||
|
||||
let clear_button = ui.button("Clear");
|
||||
if clear_button.clicked() {
|
||||
let clear_button = ui.add(button("Clear"));
|
||||
if button_clicked(clear_button) {
|
||||
input_text.value = "".to_string();
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue