p5.js icon indicating copy to clipboard operation
p5.js copied to clipboard

mouse events / key events

Open clankill3r opened this issue 12 years ago • 7 comments

I saw a issue about mouse events and touch events. I didn't want to go off topic hence the new issue.

It would be nice if p5.js has things like

void rightMousePressed() {} etc.

And support to check if multiple keys are pressed at the same time. On the processing forum the question to check for multiple key presses comes up very often.

And now where on the topic, void mouseScroll(int delta) {}

just my 3 cents

clankill3r avatar Jun 14 '14 22:06 clankill3r

the scroll definitely seems very relevant for the web, great idea! I wonder if mouse button specific methods are overdoing it though? when the mousebutton variables are available?

lmccart avatar Jun 20 '14 01:06 lmccart

@hrishit maybe this is a place to start? there are a few ideas mentioned in this issue but the one I am thinking of specifically is implementing something like

function mouseScrolled(delta) {

}

similar to mousePressed.

lmccart avatar Aug 12 '14 13:08 lmccart

Thanks Lauren, I'll start working on this. Will go through the development wiki as well and get back with queries/ideas.

hrishit avatar Aug 12 '14 17:08 hrishit

I've added the functionality and manually tested it. Looks to be working fine. Now, I've a few questions:

  1. I am not sure if I need to add a Unit Test for this as the code change is pretty minimal and self contained.
  2. I've edited one of the source files, now running grunt again would change p5.js and p5.min.js that makes sense. But some other files also got changed. Some indentation changes, dont exactly know why that happened.
  3. I've already committed my changes to my developer branch how do I get it reviewed? At this point there are some changes which I made during testing, which I'll remove after first iteration of review.

hrishit avatar Aug 13 '14 15:08 hrishit

great @hrishit! to answer your questions:

  1. I don't think a unit test is necessary for this one, it's a bit difficult to test the mouse stuff with unit tests anyway.
  2. hmm make sure your editor is set to 2 spaces tabs, but if grunt is running ok you're probably fine in terms of formatting. I would go ahead and submit all the files that changed and I can let you know if anything seems amiss.
  3. great! I think we can merge this one directly into master, so the thing to do would be to pull the master branch into your repo so you're up to date, then submit a pull request to the master branch. from there we can make sure all looks good then merge it in!

I'm going to look around for some other self-contained bugs or features and post them later today if you want to jump into any more.

lmccart avatar Aug 13 '14 17:08 lmccart

Thanks @lmccart, yes the grunt is running fine and the spacing of what I added is fine in terms of formatting. I know this as grunt was raising warning when I was using "tab" instead of two spaces (I found this very interesting and will try to figure out how this works, will ask you if any questions regarding this).

I'll also go through the issue list and let you know if I find something which is suitable for me at this stage.

hrishit avatar Aug 13 '14 19:08 hrishit

@lmccart I've made a pull request on master branch can you please review and merge or let me know if something is wrong.

hrishit avatar Aug 15 '14 09:08 hrishit