mirror of
https://github.com/emilk/egui.git
synced 2026-09-01 22:30:03 -04:00
Run a frame per queued event in egui_kittest (#5704)
This should fix the remaining problems with the modifiers * [x] I have followed the instructions in the PR template
This commit is contained in:
@@ -8,14 +8,12 @@ pub(crate) struct EventState {
|
||||
}
|
||||
|
||||
impl EventState {
|
||||
/// Map the kittest events to egui events, add them to the input and update the modifiers.
|
||||
/// Map the kittest event to an egui event, add it to the input and update the modifiers.
|
||||
/// This function accesses `egui::RawInput::modifiers`. Make sure it is not reset after each
|
||||
/// frame (Since we use [`egui::RawInput::take`], this should be fine).
|
||||
pub fn update(&mut self, events: Vec<kittest::Event>, input: &mut egui::RawInput) {
|
||||
for event in events {
|
||||
if let Some(event) = self.kittest_event_to_egui(&mut input.modifiers, event) {
|
||||
input.events.push(event);
|
||||
}
|
||||
pub fn update(&mut self, event: kittest::Event, input: &mut egui::RawInput) {
|
||||
if let Some(event) = self.kittest_event_to_egui(&mut input.modifiers, event) {
|
||||
input.events.push(event);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -219,17 +219,22 @@ impl<'a, State> Harness<'a, State> {
|
||||
self
|
||||
}
|
||||
|
||||
/// Run a frame.
|
||||
/// This will call the app closure with the queued events and current context and
|
||||
/// Run a frame for each queued event (or a single frame if there are no events).
|
||||
/// This will call the app closure with each queued event and
|
||||
/// update the Harness.
|
||||
pub fn step(&mut self) {
|
||||
self._step(false);
|
||||
let events = self.kittest.take_events();
|
||||
if events.is_empty() {
|
||||
self._step(false);
|
||||
}
|
||||
for event in events {
|
||||
self.event_state.update(event, &mut self.input);
|
||||
self._step(false);
|
||||
}
|
||||
}
|
||||
|
||||
/// Run a single step. This will not process any events.
|
||||
fn _step(&mut self, sizing_pass: bool) {
|
||||
self.event_state
|
||||
.update(self.kittest.take_events(), &mut self.input);
|
||||
|
||||
self.input.predicted_dt = self.step_dt;
|
||||
|
||||
let mut output = self.ctx.run(self.input.take(), |ctx| {
|
||||
|
||||
Reference in New Issue
Block a user