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 › selection drag
Page Index Toggle Pages: 1
selection drag (Read 504 times)
selection drag
Sep 2nd, 2007, 6:16am
 
Has anyone implemented a selection drag method in processing?
My own attempt is less than perfect, but I am at a loss as to how to improve it. My problem is that when the mouse stops moving (specifically, mouseDrag events are no longer being generated) my selection box disappears. It reappears properly when movement begins again, and it selects items appropriately, but it would be much better if it would persist when the mouse is still if the button is still pressed. Any thoughts would be much appreciated.
Re: selection drag
Reply #1 - Sep 2nd, 2007, 11:26am
 
Code:

boolean dragging = false;
int startX, startY;

void setup()
{
size(300,300);
noFill();
stroke(0);
}

void draw()
{
background(255);
if(dragging){
rect(startX,startY,mouseX-startX,mouseY-startY);
}
}
void mousePressed()
{
startX = mouseX;
startY = mouseY;
dragging = true;
}
void mouseReleased()
{

dragging = false;
}
Re: selection drag
Reply #2 - Sep 2nd, 2007, 5:15pm
 
beautiful. that is exactly what I did, except I foolishly relied on drag events, because I thought other elements of my core java app would mess it up.
thanks for the help- I had it up and running in 15 min.
Page Index Toggle Pages: 1