-
Notifications
You must be signed in to change notification settings - Fork 134
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
add pointer.Buttons to MouseClick events #25
base: main
Are you sure you want to change the base?
Conversation
this commit extends ClickEvent to include the corresponding button.
I'm not sure why go fmt is failing |
break | ||
} | ||
c.pressed = false | ||
b := c.Buttons ^ e.Buttons // the released button |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you mean "buttons" in plural?
Use full comment sentences: // The released buttons.
break | ||
} | ||
c.pressed = false | ||
b := c.Buttons ^ e.Buttons // the released button | ||
c.pressed = e.Buttons&pointer.ButtonPrimary > 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use "!=" for bitmask operations. A ">" looks like an ordered operation.
@@ -181,17 +185,17 @@ func (c *Click) Events(q event.Queue) []ClickEvent { | |||
if c.pid != e.PointerID { | |||
break | |||
} | |||
c.pressed = true | |||
events = append(events, ClickEvent{Type: TypePress, Position: e.Position, Source: e.Source, Modifiers: e.Modifiers}) | |||
c.pressed = e.Buttons&pointer.ButtonPrimary > 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
!=
@@ -37,6 +37,8 @@ type Click struct { | |||
clicks int | |||
// pressed tracks whether the pointer is pressed. | |||
pressed bool | |||
// Buttons tracks which buttons are pressed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't seem quite right. Did you mean
// Buttons specify the set of buttons to track. The zero value is equivalent to the
// primary button, not the empty set.
?
Ah, I see from the rest of your change that I wasn't clear enough in my description. What I meant by the Buttons field is that it should be set by the user from Click, not Click itself. The purpose of (the zero value of) Buttons is maintain the old behaviour where only the primary mouse button would be tracked. Users such as yourself that need to track other buttons can include them in Buttons.
@@ -37,6 +37,8 @@ type Click struct { | |||
clicks int | |||
// pressed tracks whether the pointer is pressed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this change to something like
// pressed tracks whether one or more buttons from the Buttons set is pressed.
?
@@ -131,7 +134,7 @@ func (c *Click) Hovered() bool { | |||
return c.entered | |||
} | |||
|
|||
// Pressed returns whether a pointer is pressing. | |||
// Pressed returns whether a pointer is pressing the left mouse button. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"primary mouse button". Sorry for renaming the buttons while you're working on this change :)
c.pressed = false | ||
b := c.Buttons ^ e.Buttons // the released button | ||
c.pressed = e.Buttons&pointer.ButtonPrimary > 0 | ||
c.Buttons = e.Buttons |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Click shouldn't update its Buttons field. See my comment on the field above.
899f0fa
to
94f7fa3
Compare
8ae0153
to
3f38e67
Compare
0d543a0
to
1686874
Compare
67c77c9
to
46cc311
Compare
f8029f2
to
026d3f9
Compare
1b283cb
to
632a44d
Compare
3d36537
to
74ccc9c
Compare
this commit extends ClickEvent to include the corresponding button.