Skip to content

Conversation

@z-jxy
Copy link
Contributor

@z-jxy z-jxy commented Nov 10, 2025

Objective

Solution

  • Pass position to HitData in bevy_picking::window::update_window_hits
  • Update doc comment

Testing

The following now works:

use bevy::prelude::*;

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_systems(Startup, setup)
        .run();
}

fn setup(mut commands: Commands) {
    commands.spawn(Camera2d);
    commands
        .spawn(Window::default())
        .observe(|trigger: On<Pointer<Move>>| {
            assert!(
                trigger.hit.position.is_some(),
                "Position should not be None"
            );
        });
}

@github-actions
Copy link
Contributor

Welcome, new contributor!

Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨

@alice-i-cecile alice-i-cecile added C-Bug An unexpected or incorrect behavior D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Review Needs reviewer attention (from anyone!) to move forward A-Picking Pointing at and selecting objects of all sorts labels Nov 10, 2025
@alice-i-cecile
Copy link
Member

@laundmo, can I get your review here?

@alice-i-cecile
Copy link
Member

Oh wow, that's shockingly easy. Thanks!

@alice-i-cecile alice-i-cecile added this to the 0.17.3 milestone Nov 10, 2025
@laundmo
Copy link
Contributor

laundmo commented Nov 10, 2025

I had guessed it would be easy, it seemed like an oversight to me. That's why i made it a bug report and not a feature request.

I'm glad it could be someones first contribution to bevy!

@alice-i-cecile alice-i-cecile added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Nov 10, 2025
@mockersf mockersf added this pull request to the merge queue Nov 13, 2025
Merged via the queue into bevyengine:main with commit a383e0f Nov 14, 2025
47 checks passed
ItsDoot pushed a commit to ItsDoot/bevy that referenced this pull request Nov 15, 2025
# Objective

- Mouse position from `On<Pointer<Move>>` is `None` when accessing from
an observer added to a window.
- Fixes bevyengine#21778

## Solution

- Pass position to `HitData` in
`bevy_picking::window::update_window_hits`
- Update doc comment

## Testing

The following now works:

```rust
use bevy::prelude::*;

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_systems(Startup, setup)
        .run();
}

fn setup(mut commands: Commands) {
    commands.spawn(Camera2d);
    commands
        .spawn(Window::default())
        .observe(|trigger: On<Pointer<Move>>| {
            assert!(
                trigger.hit.position.is_some(),
                "Position should not be None"
            );
        });
}
```
ItsDoot pushed a commit to ItsDoot/bevy that referenced this pull request Nov 16, 2025
# Objective

- Mouse position from `On<Pointer<Move>>` is `None` when accessing from
an observer added to a window.
- Fixes bevyengine#21778

## Solution

- Pass position to `HitData` in
`bevy_picking::window::update_window_hits`
- Update doc comment

## Testing

The following now works:

```rust
use bevy::prelude::*;

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_systems(Startup, setup)
        .run();
}

fn setup(mut commands: Commands) {
    commands.spawn(Camera2d);
    commands
        .spawn(Window::default())
        .observe(|trigger: On<Pointer<Move>>| {
            assert!(
                trigger.hit.position.is_some(),
                "Position should not be None"
            );
        });
}
```
ItsDoot pushed a commit to ItsDoot/bevy that referenced this pull request Nov 16, 2025
# Objective

- Mouse position from `On<Pointer<Move>>` is `None` when accessing from
an observer added to a window.
- Fixes bevyengine#21778

## Solution

- Pass position to `HitData` in
`bevy_picking::window::update_window_hits`
- Update doc comment

## Testing

The following now works:

```rust
use bevy::prelude::*;

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_systems(Startup, setup)
        .run();
}

fn setup(mut commands: Commands) {
    commands.spawn(Camera2d);
    commands
        .spawn(Window::default())
        .observe(|trigger: On<Pointer<Move>>| {
            assert!(
                trigger.hit.position.is_some(),
                "Position should not be None"
            );
        });
}
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Picking Pointing at and selecting objects of all sorts C-Bug An unexpected or incorrect behavior D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Window Picking backend doesn't set HitData position

5 participants