Grip / selectable

import compose.grips.*;

GripDispatcher dispatch;
CircleGrip myGrip;

void setup() {
  dispatch = new GripDispatcher(this);
  myGrip = new CircleGrip(50, 50, 40);
  myGrip.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

By default, Grip objects are not selectable. Meaning that when the mouseRelease() event fires, the Grip will no longer be active, and isTheActive() will return false. If selectable is true, this Grip will retain active status until the user clicks elsewhere.

Syntax
myGrip.selectable = true;
myGrip.selectable = false;
Parameters
None
Returns
None
Usage
Web & Applications
Related
Last Modified: March 3, 2010

No Comments

You must be logged in to post a comment.