Grip / isTheActive()

import compose.grips.*;  

GripDispatcher dispatch;  
CircleGrip grip, selectableGrip;  

void setup() {  
  dispatch = new GripDispatcher(this);  
  grip = new CircleGrip(30, 50, 30);  
  selectableGrip = new CircleGrip(70, 50, 30);  
  selectableGrip.selectable = true;
}  

void draw() {  
  dispatch.update(); // Checks for hover  
  dispatch.draw(); // Calls all the draw methods  
}  

class CircleGrip extends Grip {  

  float x, y, diameter;  

  CircleGrip(float x, float y, float diameter) {  
    this.x = x;  
    this.y = y;  
    this.diameter = diameter;  
  }  

  boolean isHovering() {  
    return dist(mouseX, mouseY, x, y) < diameter/2;  
  }  

  void draw() {  
    if (this.isTheActive()) {  
      fill(0, 255, 0);  
    } else {
      fill(255);
    }
    ellipse(x, y, diameter, diameter);  
  }  

} 

This browser does not have a Java Plug-in.
Get the latest Java Plug-in here.

Description

This method will return true if the Grip is selected by the user, and false if not. A Grip that is not selectable is “active” only as long as the mouse is pressed on that Grip. A Grip that is selectable is “active” once the mouse is pressed on that Grip, and until something else is pressed.

Syntax
class FancyGrip extends Grip {
   void anyMethod() {
      if (this.isTheActive()) {
         statements 
      }
   }
}
Parameters
None
Returns
true if selected by the user
Usage
Web & Applications
Related
Last Modified: January 25, 2010

No Comments

You must be logged in to post a comment.