top of page

White-Yellow-Black Button

Place a white square on a gray background. Turn the square into a button with a “hover” state:

Part 1: make it yellow when the user is hovering over it (without having clicked it)

Part 2: make it white when inactive (not hovering)

Part 3: make it black when the user is actively holding the mouse button down inside of it. (Source: Code as a Creative Medium)


See the sketch here


I am struggling with Part 3! I'm trying to remember if we can do an if statement within an if statement... but it seems like that's not allowed...


oh wow I got it! I was trying to tack on 'mouseIsPressed' at the end of the string after the mouseX and mouseY location, but instead I tried it at the front. And I reorganized the if statements to start with the mouseIsPressed (black), then let it be yellow if the cursor is just hovering, then white if none of the above apply.




7 views1 comment

Recent Posts

See All
bottom of page