How to make a button using when not pressed

Using when not pressed and when tapped, you can create a button that acts like this:

The first block (draw a background) is just a draw a trail (color) size 3000 move forward 1. This will cover the entire screen with the background color. The second block sets position to the center of the screen. (Width of the screen divided by two for the x, and height of the screen divided by two for the y. This will place your object in the center no matter how large or small the screen is.)
The third block changes the object from a sloth to my button shape (a circle) If you object is already what you want your button to be, this is unnecessary. The set image block allows you to change any object to any other object. Do you want that sloth to become a toucan? I don’t know why you would prefer a toucan over the majestic sloth, but it can be done by using set image to toucan.

Don’t pay any mind to the when is not pressed, I’ll get back to that later.

What's the difference between tapped and pressed?

In Hopscotch, there are three when blocks relating to your finger touching an object. Each of them either involves taps or presses. When pressed means when you hold down on the object. If you just tap it for a split second, when pressed will not fire. The opposite of it is when not pressed, which is new. The third when block relating to your finger touching an object is when tapped. This only fires when your finger first touches an object. To run when is tapped a second time, you must release the object then tap again. The opposite of it would be when released. Since that is not currently a block, we have to make our own code for it. It is pretty easy though. I’ll make a tutorial for a button using that later.

The first block sets the size to 450 percent. (The size when not pressed is 500. 450 is 90% of that. Does that fact matter? Not really.) This is why it gets smaller. The second block changes its color to a darker grey. (When it is not pressed, its color is RGB(25,26,30)) This gives you the effect in the gif. This when tapped also works as a when pressed in some way, since holding the object stops the when not pressed code from running. When you hold the object, no code is actually doing anything. Code only runs when you are either

  1. Tapping the object, or
  2. Not touching the object.

We know what code runs when you tap the object, now let’s see what happens when you are not touching it.

These two blocks go inside of a when self is not pressed block. It is basically the same as the code we looked at before, except instead of setting size to 450%, it sets size to 500%. And instead of setting color to RGB(20,21,25), it sets color to RGB(25,26,30). This code will always run as long as you are not touching the button object.

Here is a link to my project using this.


Nicely done!
*clap clap *
This is the first tutorial of this I’ve seen on the forum so far wow


Good job Nindroid
This tutorial is well written


Cool tutorial! I am probably going to try this new rule out, it sounds really cool. I haven’t done it yet though.

1 Like

Nice tutorial! This is a great use of the new block. I am probably going to try this and post it soon, so I’ll keep you updated!

How about the Is not pressed