Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix modifiers not working in kittest #5693

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

lucasmerlin
Copy link
Collaborator

It still isn't ideal, since you have to remember to call key_up on a separate frame.

@lucasmerlin lucasmerlin added bug Something is broken egui_kittest labels Feb 6, 2025
Copy link

github-actions bot commented Feb 6, 2025

Preview available at https://egui-pr-preview.github.io/pr/5693-fix-kittest-modifiers
Note that it might take a couple seconds for the update to show up after the preview_build workflow has completed.

Comment on lines +400 to +401
let modifiers = modifiers | self.input.modifiers;
let previous_modifiers = mem::replace(&mut self.input.modifiers, modifiers);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: simpler/shorter

Suggested change
let modifiers = modifiers | self.input.modifiers;
let previous_modifiers = mem::replace(&mut self.input.modifiers, modifiers);
let previous_modifiers = self.input.modifiers;
self.input.modifiers |= modifiers;

last_mouse_pos: Pos2,
}

impl EventState {
pub fn kittest_event_to_egui(&mut self, event: kittest::Event) -> Option<egui::Event> {
/// Map the kittest events to egui events, add them to the input and update the modifiers.
/// This function accesses `egui::RawInput::modifiers`, make sure it is not reset after each
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// This function accesses `egui::RawInput::modifiers`, make sure it is not reset after each
/// This function accesses `egui::RawInput::modifiers`. Make sure it is not reset after each

}

/// Press a key with modifiers.
/// This will create a key down event and a key up event.
/// This will create a key down event, a key up event and update the modifiers.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// This will create a key down event, a key up event and update the modifiers.
/// This will create a key-down event, a key-up event, and update the modifiers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is broken egui_kittest
Projects
None yet
Development

Successfully merging this pull request may close these issues.

egui_kittest: Correctly handle modifiers
2 participants