eframe: Fix clicks in web (#3640)
Closes https://github.com/emilk/egui/issues/3633 Bug introduced in #3623 (after 0.24.0 was cut)
This commit is contained in:
parent
fbccd3a1a2
commit
43e7b16bb1
|
|
@ -173,20 +173,8 @@ impl AppRunner {
|
||||||
self.painter.destroy();
|
self.painter.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Runs the user code and paints the UI.
|
pub fn has_outstanding_paint_data(&self) -> bool {
|
||||||
///
|
self.clipped_primitives.is_some()
|
||||||
/// If there is already an outstanding frame of output,
|
|
||||||
/// that is painted instead.
|
|
||||||
pub fn run_and_paint(&mut self) {
|
|
||||||
if self.clipped_primitives.is_none() {
|
|
||||||
// Run user code, and paint the results:
|
|
||||||
self.logic();
|
|
||||||
self.paint();
|
|
||||||
} else {
|
|
||||||
// We have already run the logic, e.g. in an on-click event,
|
|
||||||
// so let's only present the results:
|
|
||||||
self.paint();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Runs the logic, but doesn't paint the result.
|
/// Runs the logic, but doesn't paint the result.
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,25 @@ fn paint_and_schedule(runner_ref: &WebRunner) -> Result<(), JsValue> {
|
||||||
|
|
||||||
fn paint_if_needed(runner: &mut AppRunner) {
|
fn paint_if_needed(runner: &mut AppRunner) {
|
||||||
if runner.needs_repaint.needs_repaint() {
|
if runner.needs_repaint.needs_repaint() {
|
||||||
runner.needs_repaint.clear();
|
if runner.has_outstanding_paint_data() {
|
||||||
runner.run_and_paint();
|
// We have already run the logic, e.g. in an on-click event,
|
||||||
|
// so let's only present the results:
|
||||||
|
runner.paint();
|
||||||
|
|
||||||
|
// We schedule another repaint asap, so that we can run the actual logic
|
||||||
|
// again, which may schedule a new repaint (if there's animations):
|
||||||
|
runner.needs_repaint.repaint_asap();
|
||||||
|
} else {
|
||||||
|
// Clear the `needs_repaint` flags _before_
|
||||||
|
// running the logic, as the logic could cause it to be set again.
|
||||||
|
runner.needs_repaint.clear();
|
||||||
|
|
||||||
|
// Run user code…
|
||||||
|
runner.logic();
|
||||||
|
|
||||||
|
// …and paint the result.
|
||||||
|
runner.paint();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
runner.auto_save_if_needed();
|
runner.auto_save_if_needed();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue