clickedmousepos

versions0095+
contributorsseltar
started on2006-03-19 22:38

Very easy.. run this at the beginning of draw() and you'll get coordinates outside of the frame even when the mouse isn't clicked

/**
clickedmousepos taken from http://processinghacks.com/hacks:clickedmousepos
@author Yonas Sandbæk
*/
 
void setMouseXY() 
{
  if(mouseX>=0 && mouseX<width && mouseY>=0 && mouseY<height) return;
  Point mouse, winloc;
  mouse = MouseInfo.getPointerInfo().getLocation();
  winloc = frame.getLocation();
  if(!frame.isUndecorated()){
    winloc.x += 3;
    winloc.y += 29;
  }
  mouseX = mouse.x-winloc.x;
  mouseY = mouse.y-winloc.y;
}
hacks/clickedmousepos.txt · Last modified: 2007-07-13 02:12 (external edit)