-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
WinMouseX and WinMouseY not set properly when clicking on an option in select element #3066
Comments
I tried to recreate it, everything is working fine. Try select any option from select and you will see that winMouseX and winMouseY are not resetted to 0. If this doesn't solve the problem then I would request you to share the code just as I did. |
Hi there, considering I opened this issue a year and a half ago, I can't really provide the code I used back then. I would just like to know which version of p5.js you used when testing this? It's certainly possible that this was resolved given the time frame. |
p5.js v0.10.2 October 14, 2019 |
That might explain why you're getting a different result. I've experienced this issue on version 0.6.1, which is quite old by now |
since this might have been an old bug, |
Nature of issue?
Most appropriate sub-area of p5.js?
Which platform were you using when you encountered this?
Details about the bug:
The bug is regarding the
winMouseX
andwinMouseY
variables used in themouseReleased()
event. The documentation for the variables says that they store the current horizontal/vertical position of the mouse point relative to the origin point of the window. Now, I'm assuming window in this case means the browser window. If so, I will carry. If not, the variables are probably working as they should.I was recently experimenting with some pathfinding algorithms and so I needed a playground to run tests on. The playground consisted of a simple grid which was filling up the entire canvas (the width and height of the canvas are always equal to either the width or the height of the browser window depending if the window was in portrait or landscape mode) and right next to the canvas is a select element with some options to set walkable and unwalkable tiles on to the grid and things of that nature.
Before adding the select element, I implemented a simple
mouseReleased()
event which would just add an unwalkable node to the grid. Nothing specialBut after adding the select element next to the canvas and selecting any one of the options, the tile at position (0, 0) would get changed to an unwalkable node which is indicated by a black rectangle on the canvas. I figured, since I created the select element through p5, it probably has a
mouseReleased()
event as well and manages themouseX
andmouseY
. So I added a simple check to see if the mouse pointer is within the canvas by usingwinMouseX
andwinMouseY
Since I can't paste the entire project here, I will paste the outputs of the 3 console.logs for some of the tested situations.
Clicked inside the canvas on a tile:
Clicked outside the canvas, not on the select element:
Clicked on the select element, not on an option:
Clicked on an option inside the select element:
Now as you can see, whenever I click on a option in the select element, the
winMouseX
andwinMouseY
variables just reset to 0 even though the pointer is towards the middle of the window.The text was updated successfully, but these errors were encountered: