From b316a0ffe6f9d9cc356aff86ead0b18ab3b68184 Mon Sep 17 00:00:00 2001 From: ArztKlein <52363453+ArztKlein@users.noreply.github.com> Date: Mon, 27 Jun 2022 15:55:55 +1200 Subject: [PATCH] Add cursor styling resolves #14 --- library/p5.clickable.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/library/p5.clickable.js b/library/p5.clickable.js index 525fd35..12d5fc6 100644 --- a/library/p5.clickable.js +++ b/library/p5.clickable.js @@ -11,11 +11,14 @@ var cl_clickables = []; //each draw cycle. p5.prototype.runGUI = function () { for (i = 0; i < cl_clickables.length; ++i) { - if (cl_lastHovered != cl_clickables[i]) + if (cl_lastHovered != cl_clickables[i]){ + cursor("initial"); // Reset the cursor as it is no longer hovering the clickable. cl_clickables[i].onOutside(); + } } if (cl_lastHovered != null) { if (cl_lastClicked != cl_lastHovered) { + cursor(cl_lastHovered.hoverCursorStyle); cl_lastHovered.onHover(); } } @@ -69,6 +72,7 @@ function Clickable(x,y) { this.textSize = 12; //Size for the text shown this.textFont = "sans-serif"; //Font for the text shown this.textScaled = false; //Scale the text with the size of the clickable + this.hoverCursorStyle = "pointer" //The cursor style when clickable is hovered // image options this.image = null; // image object from p5loadimage()