How to make a button that gets "off" while finger is still on display

I hope my question is clear:
I want two buttons side by side to move a sprite left or right. I would like to have the thumb not lifted from the display so that the other button is triggered. the finger should “slide” on the display. with which block is this possible?

it doesn’t work with GOT FOCUS or with LOST FOCUS or I didn’t get it.


Use fake buttons rendered on a Canvas using sprites. Use the touch coordinates to see which button, if any, should be active.

1 Like

This also only works, when I release the fingers off the display for a moment.

No. Use the “Dragged” event handler. :man_shrugging:

Improvise. Adapt. Overcome.


Have you considered using a slider component instead of a pair of buttons?
Have the slider rely on “position changed” value event trap to determine if the touch point is left or right of center.

The other suggestion to use a canvas would also work, but a canvas is a bit more resource intensive.

Slider is not an option, but the idea with canvas and “dragged” seems to be it. I have to learn how this works.

1 Like

I’m going to make a circular fake button, where the thumb can move in any direction. So I have to determine from where in which direction the thumb is moved. I sincerely hope that when changing direction you will still be able to tell where the thumb first touched the display (startX startY) and make all movements dependent on it.

Problems maybe: Canvas size and fixed pixels on various displays

We will see. I like to try it. Especially because I will certainly get help here if I do not know what to do.

1 Like

Make the canvas a % size instead of fixed pixel. At least you will have a standard behavior that is consistent across devices.
But (and that is the clever bit) you can get the “canvas.width” and “canvas.height” out, and those values are returned in pixel, a value that is consistent with the position of anything drawn in it.
For instance, if you are touching the dead center of the canvas, then the X and Y value will be canvas.width/2 and canvas.height/2.
By setting the canvas in %, but internally processing based on calculations based on canvas.height and canvas.width (expressed in pixels) you simply create the reference that will naturally adapt to the device on which the app is installed.

1 Like

Canvas already is % Size fullscreen (parent).

Thanks for the hint with canvas.width. Thats really good news.

I always liked the way this user made a “joystick”.


this is very good. I can take a look into the blocks and I will understand so much more quickly how that is related to each other than to read the documentation of MIT AI.

There are some interesting math formulas I have to study. And I think in a few days or weeks I will understand the whole blocks. I hope so…


Another question, maybe silly but it must be clear for me:
Take a look at this block

In Maths, the PEMDAS-rules applies. But here is a little block in the bigger block.
Which formula does the whole block calculate first?

I am sure, this is coding basic knowlegde. I want to know this.

I just remembered that I can easily test it out for myself. Please excuse.

Ok the inner block is calculated first.


This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.