Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Examples] mouse-state example seems to have its outputs switched #1353

Open
MichaelZalla opened this issue Dec 13, 2023 · 1 comment
Open

Comments

@MichaelZalla
Copy link

In the mouse-state example, the changes to the mouse's button states are logged as "${new_buttons} -> ${old_buttons}":

// Get the difference between the new and old sets.
let new_buttons = &buttons - &prev_buttons;
let old_buttons = &prev_buttons - &buttons;
if !new_buttons.is_empty() || !old_buttons.is_empty() {
println!(
"X = {:?}, Y = {:?} : {:?} -> {:?}",
state.x(),
state.y(),
new_buttons,
old_buttons
);

A left-click (mouse-down, then mouse-up) inside the window generates this output:

X = 605, Y = 300 : {Left} -> {}
X = 605, Y = 300 : {} -> {Left}

Shouldn't this order be reversed? I would expect to see:

X = 605, Y = 300 : {} -> {Left}
X = 605, Y = 300 : {Left} -> {}

More output:

X = 605, Y = 300 : {Left} -> {}
X = 605, Y = 300 : {} -> {Left}
X = 828, Y = 161 : {Right} -> {}
X = 828, Y = 161 : {} -> {Right}
X = 232, Y = 312 : {Left} -> {}
X = 232, Y = 312 : {} -> {Left}
X = 234, Y = 337 : {Left} -> {}
X = 234, Y = 337 : {} -> {Left}
X = 712, Y = 134 : {Right} -> {}
X = 712, Y = 134 : {} -> {Right}
X = 813, Y = 283 : {Right} -> {}
X = 813, Y = 283 : {} -> {Right}
@Cobrand
Copy link
Member

Cobrand commented Dec 18, 2023

You're right, there is an error in the display, lines 49 and 50 should be swapped.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants