Skip to content
Open
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
title: PointerButton is now MouseButton.
pull_requests: [25392]
---

Bevy picking used `PointerButton` for reasons...?
This was limiting as it only exposed 3 buttons.
It is also seemingly redundant, and now has been replaced with `MouseButton`.

```rust
PointerButton::Primary -> MouseButton::Left
PointerButton::Middle -> MouseButton::Middle
PointerButton::Secondary -> MouseButton::Right
```

Before:
```rust
MousePanSettings {
enabled: true,
button: MouseButton::Left,
}
```
After:
```rust
MousePanSettings {
enabled: true,
button: PointerButton::Primary,
}
```
6 changes: 4 additions & 2 deletions crates/bevy_app/src/panic_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ impl Plugin for PanicHandlerPlugin {
cfg_select! {
all(target_arch = "wasm32", feature = "web") => {
// This provides better panic handling in JS engines (displays the panic message and improves the backtrace).
std::panic::set_hook(alloc::boxed::Box::new(console_error_panic_hook::hook));
std::panic::set_hook(alloc::boxed::Box::new(
console_error_panic_hook::hook,
));
}
feature = "error_panic_hook" => {
let current_hook = std::panic::take_hook();
Expand All @@ -55,7 +57,7 @@ impl Plugin for PanicHandlerPlugin {
));
}
// Otherwise use the default target panic hook - Do nothing.
_ => ()
_ => (),
}
});
}
Expand Down
16 changes: 7 additions & 9 deletions crates/bevy_app/src/schedule_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,17 +157,15 @@ impl Plugin for ScheduleRunnerPlugin {

exit.take()
}
_ =>{
loop {
match tick(&mut app, wait) {
Ok(Some(delay)) => {
bevy_platform::thread::sleep(delay);
}
Ok(None) => continue,
Err(exit) => return exit,
_ => loop {
match tick(&mut app, wait) {
Ok(Some(delay)) => {
bevy_platform::thread::sleep(delay);
}
Ok(None) => continue,
Err(exit) => return exit,
}
}
},
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_app/src/task_pool_plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use log::trace;

cfg_select! {
not(all(target_arch = "wasm32", feature = "web")) => {
use {crate::Last, bevy_tasks::tick_global_task_pools_on_main_thread};
use bevy_ecs::system::NonSendMarker;
use {crate::Last, bevy_tasks::tick_global_task_pools_on_main_thread};

/// A system used to check and advanced our task pools.
///
Expand Down
10 changes: 4 additions & 6 deletions crates/bevy_camera_controller/src/pan_camera.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@ use bevy_camera::{Camera, RenderTarget};
use bevy_ecs::prelude::*;
use bevy_input::keyboard::KeyCode;
use bevy_input::mouse::{AccumulatedMouseScroll, MouseScrollPixelsPerLine};
use bevy_input::prelude::MouseButton;
use bevy_input::ButtonInput;
use bevy_math::{Vec2, Vec3};
use bevy_picking::{
events::{Drag, DragEnd, DragStart, Pointer},
pointer::PointerButton,
};
use bevy_picking::events::{Drag, DragEnd, DragStart, Pointer};
use bevy_time::{Real, Time};
use bevy_transform::components::GlobalTransform;
use bevy_transform::prelude::Transform;
Expand Down Expand Up @@ -90,7 +88,7 @@ pub struct MousePanSettings {
/// Whether the mouse panning is enabled.
pub enabled: bool,
/// The mouse button to use for panning.
pub button: PointerButton,
pub button: MouseButton,
}

#[derive(Eq, PartialEq)]
Expand Down Expand Up @@ -145,7 +143,7 @@ impl Default for PanCamera {
key_rotate_cw: Some(KeyCode::KeyE),
mouse_pan_settings: MousePanSettings {
enabled: true,
button: PointerButton::Primary,
button: MouseButton::Left,
},
}
}
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_feathers/src/controls/number_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use bevy_ecs::{
};
use bevy_input::{
keyboard::{Key, KeyCode, KeyboardInput},
mouse::MouseButton,
ButtonInput,
};
use bevy_input_focus::{FocusGained, FocusLost, FocusedInput, InputFocus, InputFocusSystems};
Expand All @@ -27,7 +28,6 @@ use bevy_picking::{
cursor::EntityCursor,
events::{Cancel, Drag, DragEnd, DragStart, Pointer, Press, Release},
hover::Hovered,
pointer::PointerButton,
PickingSystems,
};
use bevy_platform::collections::HashMap;
Expand Down Expand Up @@ -1015,7 +1015,7 @@ fn scrubber_on_release(

// Copy of logic from EditableText / text_input, but done on pointer up instead of down.
if drag_state.max_distance <= DRAG_THRESHOLD_DISTANCE {
if release.button != PointerButton::Primary {
if release.button != MouseButton::Left {
return;
}

Expand Down
Loading