We are about to switch to a new forum software. Until then we have removed the registration on this forum.
In a class i have:
p.registerMethod("mouseEvent", this);
I need to know the even for the following:
public void mouseEvent(MouseEvent e){
if (currentMode == null) return;
// call mousePressed(), mouseClicked(), mouseDragged() etc. in currentMode
}
How do i get the event?
Answers
There's no variable called currentMode in Processing's API. So I dunno what are you checking against! :@)
sorry currentMode is something i made. In currentMode i also have mousePressed() etc. And what i want to do is that when currentMode exist make a call like:
currentMode.mousePressed();
Still very confusing. Is currentMode a PApplet reference just like p?
Why do you need both? Your concoction is still a mystery! [..]
I need to know from
MouseEvent e
what kind of event it is. :)This is its source code:
https://github.com/processing/processing/blob/master/core/src/processing/event/Event.java
https://github.com/processing/processing/blob/master/core/src/processing/event/MouseEvent.java
This might help
Seems like I'm lacking cognitive skills:
* Is MyObject() supposed to be the constructor for class MouseHandler?
* Again, the mysterious field currentMode pops up outta nowhere!
In short, my Processing v2.0.2 can't compile that!!! [..]
I started calling the class MyObject and changed it to MouseHandler and forgot to change the ctor. I have now corrected that now.
True the code will not compile because of the currentMode so I have now removed that now.
Perhaps I should have said that the code wasn't tested but it was only to show how to structure a possible solution. :)
@quark, I believe your code only scratches whatever @clankill3r is brewing.
He said: "In currentMode i also have mousePressed()." Even though he's yet to tell us what type that field actually is!
So it's more complicated than we think it is. And @clankill3r expects to know how to help him out anyways!
P.S.: You use mousePress() instead of mousePressed()! ;)
@GoToLoop - I agree we haven't got the full story yet.
I suspect that currentMode is an object instantiated from a class he has created, which is why I provided an outline class.
When I typed the code I used mousePress instead of mousePressed because it matches the action type, if he wants to use mousePressed instead - no problem. :)
Quark is right :) And thanks for the code.
I jus have different displayModes and to have interaction i want each of them to have own events. But i figured my old way is better since it gives more control. For example: