Lab App - Image move with mouse

Hi,

Can someone please let me know what UI control will allow an image to move with the mouse. Or an image move with the press of the arrow keys. Thanks!

From what I have seen from the applab documentation, I don’t think that is possible. https://docs.code.org/applab/
However, I will inquire further.

1 Like

@mlarrubia

Check Unit 5 Stage 14 for the use of the keyboard to move an image. There is some documentation on the onEvent help on how to get an image to follow the mouse. It involves using event.x and event.y for the location of the image.

Andrea

2 Likes

Hi @mlarrubia,

Here is an example app that has an image which just follows the mouse.

Hope it helps!

-Dani

1 Like

Thanks Dani, I emailed you, can you please take a look at the program if you have a second.

anmrobnott - Thanks This helped!

Here’s a video I just made explaining how to implement movement of an image using the arrow keys. You can do the same sort of thing with the mousemove events if you want to tie it to mouse movement instead.

None of the links here work anymore. I want to solve the same problem. I made a manipulative in App Lab for understanding Binary Search for the CSA class. I’m trying to get clicking on a screen element to follow the mouse. I was able to do a work around where I could get it to follow with a first click, and then stop following with a second click using booleans (look at my code lines 176 to the end). For context, you are clicking the green elements on the screen. But I couldn’t figure out how to get it to follow with a held click and then stop following with a mouse release-- which would probably be the best functionality. If anyone has any ideas, let me know.

1 Like