mirror of
https://github.com/emilk/egui.git
synced 2026-08-29 04:40:03 -04:00
Harness: Add remove_cursor, event and event_modifiers (#7607)
* Closes https://github.com/emilk/egui/issues/7591
This commit is contained in:
@@ -460,11 +460,15 @@ impl<'a, State> Harness<'a, State> {
|
||||
&mut self.state
|
||||
}
|
||||
|
||||
fn event(&self, event: egui::Event) {
|
||||
/// Queue an event to be processed in the next frame.
|
||||
pub fn event(&self, event: egui::Event) {
|
||||
self.queued_events.lock().push(EventType::Event(event));
|
||||
}
|
||||
|
||||
fn event_modifiers(&self, event: egui::Event, modifiers: Modifiers) {
|
||||
/// Queue an event with modifiers.
|
||||
///
|
||||
/// Queues the modifiers to be pressed, then the event, then the modifiers to be released.
|
||||
pub fn event_modifiers(&self, event: egui::Event, modifiers: Modifiers) {
|
||||
let mut queue = self.queued_events.lock();
|
||||
queue.push(EventType::Modifiers(modifiers));
|
||||
queue.push(EventType::Event(event));
|
||||
@@ -584,6 +588,16 @@ impl<'a, State> Harness<'a, State> {
|
||||
self.key_combination_modifiers(modifiers, &[key]);
|
||||
}
|
||||
|
||||
/// Remove the cursor from the screen.
|
||||
///
|
||||
/// Will fire a [`egui::Event::PointerGone`] event.
|
||||
///
|
||||
/// If you click a button and then take a snapshot, the button will be shown as hovered.
|
||||
/// If you don't want that, you can call this method after clicking.
|
||||
pub fn remove_cursor(&self) {
|
||||
self.event(egui::Event::PointerGone);
|
||||
}
|
||||
|
||||
/// Mask something. Useful for snapshot tests.
|
||||
///
|
||||
/// Call this _after_ [`Self::run`] and before [`Self::snapshot`].
|
||||
|
||||
Reference in New Issue
Block a user