We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › More mouse event
Page Index Toggle Pages: 1
More mouse event? (Read 2087 times)
More mouse event?
Jun 28th, 2009, 8:12am
 
In the term of mouse event,can I access some more useful codes like "mouseDown" for dealing with events happens at the moment the mouse is pressed down but not in the following time interval?Thank you for your help.
Re: More mouse event?
Reply #1 - Jun 28th, 2009, 10:55am
 
Not entirely sure I understand the question, but the answer is probably: see 'Related' under mouseButton.
Re: More mouse event?
Reply #2 - Jun 28th, 2009, 5:17pm
 
Thank you,but are there any 'more' syntaxes?I mean:apart from these in the tutorial page?Thank you.
Re: More mouse event?
Reply #3 - Jun 29th, 2009, 12:31am
 
It might help if you explained what you need...  There's obviously Java documentation on mouse events (e.g. here and here); but that may not all work as expected within Processing.  It would appear that a mouseListener object is created, but not so clear how it can be referenced directly, if at all.

From a little play around some MouseEvent methods can be called successfully, but not all of them return values you might expect (e.g. getClickCount() )...
Re: More mouse event?
Reply #4 - Jun 29th, 2009, 11:31am
 
It just so happens I came across a reference to mouse related stuff whilst looking through Ira Greenberg's book today.  The mouse event object is called... wait for it ... 'mouseEvent' Smiley

So you can reference this and call methods from the mouseEvent class:

Code:
void setup() {
 size(200,200);  
}

void draw() {
   
}

void mousePressed() {
 println( mouseEvent.getPoint() );
 // it seems that any other mouse event resets the Click counter...
 println( "number of clicks: " + mouseEvent.getClickCount() );
 println("button: " + mouseEvent.getButton() );
 println("--------------------------------------");
}

void mouseReleased() {
 println("--------------------------------------");
}

// Try moving the sketch window around your screen
// and then dragging inside it to the see the relevance of this.
void mouseDragged() {
   println("x: " + mouseEvent.getLocationOnScreen().x + "   y: " +   mouseEvent.getLocationOnScreen().y);  
}

// There's an interesting disparity between values returned by getPoint and mouseX/Y,
// specifically on mouseEntered...
void mouseEntered(MouseEvent mouseEvent) {
 println("entered at: " + mouseEvent.getPoint().x + "," + mouseEvent.getPoint().y);
 println("           " + mouseX + "," + mouseY);
 println("--------------------------------------");  
}

void mouseExited(MouseEvent mouseEvent) {
 println("exited at: "+ mouseEvent.getPoint().x + "," + mouseEvent.getPoint().y);  
 println("           " + mouseX + "," + mouseY);
 println("--------------------------------------");  
}

Fantastic!
Reply #5 - Jun 29th, 2009, 8:36pm
 
Grin
What a vision expanding work!Thank you indeed!
Page Index Toggle Pages: 1