mirror of
https://github.com/bevyengine/bevy
synced 2024-11-27 07:00:18 +00:00
Renamed left and right.
This commit is contained in:
parent
4d007cabba
commit
3969f2de3d
2 changed files with 24 additions and 18 deletions
|
@ -231,16 +231,22 @@ bitflags::bitflags! {
|
||||||
#[reflect(Hash, PartialEq, Debug)]
|
#[reflect(Hash, PartialEq, Debug)]
|
||||||
/// Button pressed in a [`PickingInteraction`]
|
/// Button pressed in a [`PickingInteraction`]
|
||||||
pub struct PressedButtons: u8 {
|
pub struct PressedButtons: u8 {
|
||||||
/// Primary mouse button is pressed.
|
/// Left mouse button is pressed.
|
||||||
const PRIMARY = 1;
|
const LEFT = 1;
|
||||||
/// Secondary mouse button is pressed.
|
/// Right mouse button is pressed.
|
||||||
const SECONDARY = 2;
|
const RIGHT = 2;
|
||||||
/// Middle mouse button is pressed.
|
/// Middle mouse button is pressed.
|
||||||
const MIDDLE = 4;
|
const MIDDLE = 4;
|
||||||
/// Touch input is pressed.
|
/// Touch input is pressed.
|
||||||
const TOUCH = 8;
|
const TOUCH = 8;
|
||||||
/// Custom input is pressed.
|
/// Custom input is pressed.
|
||||||
const CUSTOM = 16;
|
const CUSTOM = 16;
|
||||||
|
/// X1 or back, reserved, currently does nothing.
|
||||||
|
const X1 = 32;
|
||||||
|
/// X2 or forward, reserved, currently does nothing.
|
||||||
|
const X2 = 64;
|
||||||
|
/// Left mouse button or touch input is pressed.
|
||||||
|
const LEFT_OR_TOUCH = 1|8;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -248,10 +254,10 @@ impl From<PointerPress> for PressedButtons {
|
||||||
fn from(value: PointerPress) -> Self {
|
fn from(value: PointerPress) -> Self {
|
||||||
let mut result = PressedButtons::empty();
|
let mut result = PressedButtons::empty();
|
||||||
if value.is_primary_pressed() {
|
if value.is_primary_pressed() {
|
||||||
result |= PressedButtons::PRIMARY;
|
result |= PressedButtons::LEFT;
|
||||||
}
|
}
|
||||||
if value.is_secondary_pressed() {
|
if value.is_secondary_pressed() {
|
||||||
result |= PressedButtons::SECONDARY;
|
result |= PressedButtons::RIGHT;
|
||||||
}
|
}
|
||||||
if value.is_middle_pressed() {
|
if value.is_middle_pressed() {
|
||||||
result |= PressedButtons::MIDDLE;
|
result |= PressedButtons::MIDDLE;
|
||||||
|
@ -344,24 +350,24 @@ mod test {
|
||||||
#[test]
|
#[test]
|
||||||
fn merge_interaction() {
|
fn merge_interaction() {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
Pressed(PressedButtons::PRIMARY) | Pressed(PressedButtons::SECONDARY),
|
Pressed(PressedButtons::LEFT) | Pressed(PressedButtons::RIGHT),
|
||||||
Pressed(PressedButtons::PRIMARY | PressedButtons::SECONDARY)
|
Pressed(PressedButtons::LEFT | PressedButtons::RIGHT)
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
Pressed(PressedButtons::PRIMARY) | Hovered,
|
Pressed(PressedButtons::LEFT) | Hovered,
|
||||||
Pressed(PressedButtons::PRIMARY)
|
Pressed(PressedButtons::LEFT)
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
Hovered | Pressed(PressedButtons::PRIMARY),
|
Hovered | Pressed(PressedButtons::LEFT),
|
||||||
Pressed(PressedButtons::PRIMARY)
|
Pressed(PressedButtons::LEFT)
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
Pressed(PressedButtons::PRIMARY) | None,
|
Pressed(PressedButtons::LEFT) | None,
|
||||||
Pressed(PressedButtons::PRIMARY)
|
Pressed(PressedButtons::LEFT)
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
None | Pressed(PressedButtons::PRIMARY),
|
None | Pressed(PressedButtons::LEFT),
|
||||||
Pressed(PressedButtons::PRIMARY)
|
Pressed(PressedButtons::LEFT)
|
||||||
);
|
);
|
||||||
assert_eq!(Hovered | None, Hovered);
|
assert_eq!(Hovered | None, Hovered);
|
||||||
assert_eq!(None | Hovered, Hovered);
|
assert_eq!(None | Hovered, Hovered);
|
||||||
|
|
|
@ -33,12 +33,12 @@ fn picking(sprite: Query<(&PickingInteraction, &Children)>, mut text: Query<&mut
|
||||||
while let Some(mut text) = iter.fetch_next() {
|
while let Some(mut text) = iter.fetch_next() {
|
||||||
match interaction {
|
match interaction {
|
||||||
PickingInteraction::Pressed(pressed_buttons)
|
PickingInteraction::Pressed(pressed_buttons)
|
||||||
if pressed_buttons.contains(PressedButtons::PRIMARY) =>
|
if pressed_buttons.contains(PressedButtons::LEFT) =>
|
||||||
{
|
{
|
||||||
text.0 = "Left Clicked!".into();
|
text.0 = "Left Clicked!".into();
|
||||||
}
|
}
|
||||||
PickingInteraction::Pressed(pressed_buttons)
|
PickingInteraction::Pressed(pressed_buttons)
|
||||||
if pressed_buttons.contains(PressedButtons::SECONDARY) =>
|
if pressed_buttons.contains(PressedButtons::RIGHT) =>
|
||||||
{
|
{
|
||||||
text.0 = "Right Clicked!".into();
|
text.0 = "Right Clicked!".into();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue