Slider with loop in Positionchanged event

I think it is not possible but I hope someone will prove me wrong.
I want to perform a Do loop based on the thumbposition value, but it never detects the positionchanged while it’s doing the loop so it’s stuck in the loop.
I do it with buttons at the moment but a slider seemed a neat way of doing it

Please provide a more detailed explanation of what you are trying to achieve,
what you have done so far, what works, what doesn’t work…

Please show your relevant blocks,
if relevant, your data or lists,
screenshots of the Designer screen or app in action,
so we can see what you are trying to do…

Right Click in Blocks Editor and select “Download Blocks as Image”
for the best image of your blocks.

The Slider has an event block to catch when the thumb moved.
That’s where you put your movement code.
There is no need for a loop, since the event code fires over and over as the thumb is moved.

Thank you for your response. At present I have 9 buttons, a central button with 2 each side, above and below which send commands via Bluetooth to control stepper motors. They manipulate a camera up, down, left and right, with the outermost buttons moving a lot more than the inner buttons. Each button touchdown event sets a variable then enables the clock, the clock runs the code that sends the commands and the button touchup event disable it. This all works well but I thought 2 sliders with values from -2 to 2 would replace the buttons. The problem is there is only 1 event for a slider so I can set my variable and enable the click when moved to -1 etc. but I can’t see a way to disable it?

Thanks for your response, I have explained more to the reply below

A thin Canvas can be a very nice Slider, and
it has TouchUp and TouchDown events in addition to Drag events.
You can also make them vertical or horizontal.

I use a Ball as the thumb, and keep it centered as it drags.

To stack up a series of timed commands, consider a queue:
https://groups.google.com/d/msg/mitappinventortest/BOj2-ThEe3s/VlmXdcVOAgAJ

1 Like

Thanks, I’ve had a quick look at Canvas and Sprites but not in depth, I only started using MIT in the last couple of weeks. I don’t think the queued actions would work as I have to respond quickly and unpredictability to birds landing on feeders in my garden. It’s been a great project and it works and it isn’t possible to buy what I’ve made so very pleased, and I’ve learned loads using Arduino, MIT, made the motor supports with my 3D printer etc.
Incidentally, my one disappointment is not being able to have buttons arranged in a circular pattern around a circle, like a joystick, but your solution sounds great so I’ll look at that tomorrow.

See here, work by Italo on a Circular slider

1 Like

I created an extension that adds TouchDown and TouchUp Events.
Maybe this will fulfill your needs:

2 Likes

Let me know if the circular slider @TIMAI2 mentioned is something you can use and may be I can adapt it for your particular needs.

1 Like

After reading this a little bit better, I understand you need something like a joystick controller, is that right? Would you be able to show your app or a video of the screen and how you use it?

1 Like

Thanks all for your suggestions and willingness to share, I am using a ball on canvas and the drag event which is looking great so far, thanks Abraham

2 Likes

Okay, a further question. I have had a good play with Canvas, Ball and Sprite, and also simplified my requirement to moving left, right, up and down. I was hoping that if I dragged the ball I could use a Sprite to force it to go in one of these four directions with collisions, but it seems you can only move the Sprite you collide with and not what you are dragging. I guess that makes sense as what you are dragging would no longer be under your finger. Unless there is a way of constraining what is being dragged I can calculate the relative x and y distances from the centre of the canvas to work out the direction

That’s called Sprite Cannibalism.

See this thread …
https://groups.google.com/forum/#!msg/mitappinventortest/FuVKBNJwjfg/srrPgAmTCgAJ

Then you once again for your help. That doesn’t really describe my issue, I just want to force the dragging of a ball, or Sprite, to horizontal and vertical

Aha, I have realised the solution - edge collided!
I will make the canvas a little larger than the ball so a small movement will trigger the event, then return it to centre canvas on touchup :blush:

1 Like