preventDefault for input
I removed the prevent default calls as they were breaking functionality of the page sometimes. but we might want some way to specify this as the user.
https://github.com/lmccart/p5js.org/issues/34 https://github.com/lmccart/p5.js/commit/f431979f93ef273c7835c966b85f90a47baebdec
Cant the user do it inside the user defined function. i.e. button.mouseClicked(userFunc); function userFunc(e) { e.preventDefault(); }
I mean what is wrong with this? Anyhow the use will need to pass some parameter even if we decide to do this as a part of internal code. We will only complicate things for ourselves. Makes sense?
P.S. I can still see the preventDefault for touch methods. Are those left out on purpose?
yes, I think you're right! maybe all that's needed then is some explanation / examples in the reference showing how to do this.
I left it on for touch because the default behavior conflicts more than with mouse. for example, if you defined a touchMoved event on mouse, moving your finger around the screen will also drag the frame around on safari. I thought it might be better for it to just work for beginners rather than having to add the preventDefault workaround. it does leave the question of how you might restore the default if you did want the behavior though.
hmmm...makes sense. And I was also thinking of something like having a "forcedefault" kind of function or documenting it if JS provides it internally. Will update the thread if find one or a feasible solution.
Sorry, got busy with other things in between. There's no simple way of restoring the default event in JS, at least I did not find any. Here is what we can do: we can listen to the mouseclick function by user and if we get false as a response then refrain from doing the preventDefault. If this seems valid then I'll make the changes and submit a pull request.
ah ok, so let me make sure I understand, we could set up it so if a user defines a function like
function mousePressed() {
// do some stuff
return false;
}
then the default would be prevented, but without that return false line the default would fire too?
I think this sounds great, and is a little simpler than calling e.preventDefault().
closed with https://github.com/lmccart/p5.js/pull/352, nice!