Best method for a scrollable window?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Matty101

I’ve been trying to make a “window” where i can drag around the image by using the mouse as shown by the blue area in this clip:

Currently i’m doing that by changing the texture region to match the mouse movements. This makes it really easy, but for the life of me i can’t seem to change the texture used for the image.

Someone mentioned using a bunch of sprites rather than changing the data for one but i can’t see a way to only show part of the sprites if the layer is moved.

:bust_in_silhouette: Reply From: jluini

You can use ScrollContainer.

Just add a ScrollContainer as your “window”, set its size and position, and add a Control to it with the desired min-size as content.

Ahh i’ll give this a look…thx.

Matty101 | 2020-04-20 05:50

just had a look and it seems to require scroll bars to move a scrollcontainer, thats not what i’m after.
I want to be able to move the panel around with the mouse but without bars by dragging from anywhere within the panel.

Matty101 | 2020-04-22 16:57

:bust_in_silhouette: Reply From: jluini

You can use ScrollContainer or build a custom scrolling Control.

To build a custom one you just need a container Control with rect → clip_content = true and with a single Control child with the content (the child should be bigger than the container).
When you need to scroll change the content position between zero and his size less the container size and you are done.