Grip / isHovering()
import compose.grips.*; GripDispatcher dispatch; CircleGrip myGrip; void setup() { dispatch = new GripDispatcher(this); myGrip = new CircleGrip(50, 50, 40); } 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.isHovering()) { fill(255, 255, 0); } else { fill(255); } ellipse(x, y, diameter, diameter); } }- Description
Called by GripDispatcher to qualify this Grip for “hover” status. Implement this method with logic that determines whether or not the mouse is contained by this Grip’s geometry.
By default, this method always returns
false, so GripDispatcher won’t ever know if your mouse is on top of the Grip. Until you implement this method GripDispatcher cannot broadcast events to your Grip.Multiple Grip objects may return true for this method in a given update cycle, but only one will be selected as the hover, whichever is closest to the front of the screen.
- Syntax
class FancyGrip extends Grip { boolean isHovering() { return true or false } }- Parameters
- None
- Returns
- True if the mouse is contained by this Grip's geometry.
- Usage
- Web & Applications
- Related
No Comments
You must be logged in to post a comment.