mirror of
https://github.com/bevyengine/bevy
synced 2024-11-21 20:23:28 +00:00
Add button_just_down
and button_just_up
methods to PointerInput
(#16176)
# Objective Upstream two small methods present in `bevy_mod_picking` but not in `bevy_picking`. There might be a few more of these.
This commit is contained in:
parent
03372e590d
commit
9a0c9b9e8f
1 changed files with 20 additions and 0 deletions
|
@ -286,6 +286,26 @@ impl PointerInput {
|
|||
}
|
||||
}
|
||||
|
||||
/// Returns true if the `target_button` of this pointer was just pressed.
|
||||
#[inline]
|
||||
pub fn button_just_pressed(&self, target_button: PointerButton) -> bool {
|
||||
if let PointerAction::Pressed { direction, button } = self.action {
|
||||
direction == PressDirection::Down && button == target_button
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns true if the `target_button` of this pointer was just released.
|
||||
#[inline]
|
||||
pub fn button_just_released(&self, target_button: PointerButton) -> bool {
|
||||
if let PointerAction::Pressed { direction, button } = self.action {
|
||||
direction == PressDirection::Up && button == target_button
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
/// Updates pointer entities according to the input events.
|
||||
pub fn receive(
|
||||
mut events: EventReader<PointerInput>,
|
||||
|
|
Loading…
Reference in a new issue