Draggable GUI Elements Module

So I guess the new module doesnā€™t have off-screen limits? :sad:

1 Like

Sorry, I did not bother adding it, because I was having a hard time just coming up a good function name for it. :yum:

3 Likes

Well I managed to implement it pretty easily so thereā€™s no need for it now, but thanks for getting back!

3 Likes

I just updated the module, adding in the new feature, which is the boundary property.

2 Likes

Thanks for the update! I do wonder, does the frame go out of bounds if the X/Y size is increased? Does it take into account the AnchorPoint?

3 Likes

Iā€™m not sure what you mean by which size is increased, but most of the calculations are done when the InputBegan is called, such as the offset of the mouse to the GuiObject, and if there is a boundary, calculate the top left corner and the bottom right corner of the boundary.

While the InputChanged is simply adding the offset and mouse position, if there is a boundary set, it clamps the new position from corner to corner.

And yes, it considers the AnchorPoint.

2 Likes

I likes this module but usually I prefer the all-in-one so if I have a frame draggable I would also add resizing frame would it be possible to integrate frame resizing with this module somehow? And would there be a problem with the main window if the player just resize their window application?
Was planning to makes this giant command prompt with console log be draggable and can resizing so it would makes the experience of not having something taken half the whole screen.

2 Likes

Implementing GuiObjectā€™s resizing is definitely something Iā€™ve considered. Maybe once I have the time I might actually implement it.

That depends on the current configuration. Currently, it uses UDim2.fromOffset, but Iā€™m planning to introduce an option to select fromScale or fromOffset, also an option for defining minimum scale or offset values.

2 Likes

Hey there! Been trying to figure the module out but for whatever reason I just canā€™t get it to dragā€¦ Followed the documentation and all but it justā€¦ Wonā€™t drag.

It does detect that the GUI has the draggable module bound to it, it just, wonā€™t really detect the draggingā€¦

local Draggable = require(Modules.Draggable)

local Mainpanel = script.Parent.MainPanel

local DraggingUI = Draggable.new(Mainpanel)

print(DraggingUI.Enabled) --Prints out true

DraggingUI.Began:Connect(function() --Doesn't print anything...?
	print("Dragging")
end)

(For further reference, hereā€™s the UIā€™s composition in explorer)
image

Got any idea as to why?

2 Likes

Make sure that the GuiObjectā€™s Interactable is set to true:
image

1 Like

image
yep, seems set true to meā€¦ Still doesnā€™t work.

2 Likes

Is the MainPanel being obstructed by Background or any other GuiObject, if it is then I suggest to use the Include method.

2 Likes

Yo, this is a really helpful module, but Iā€™ve been wondering if thereā€™s a way to make the draggable UI boundaries work on the right and bottom of the, well, boundaries?

For some reason, if I try to push the UI to the left or top of the UI I set as the boundary, the UI stops being dragged, but if I try to move it to the right or bottom, it just keeps moving

1 Like

Hello! My new resource DragUI can help with this!

The module features a way to allow bounded dragging via position or the bounds of your draggable element.

Check out the documentation and example code and try to produce your desired result, if you run into any issue or have any questions please reply on the resourceā€™s thread and I will respond right away.

Hope this helps!

maybe you could use the UIDragDetector but it will only be available in studio right now


It doesnā€™t seem to be available anymore

My apologies, here you go. If you need help PM me and I will respond asap.
:slight_smile:

1 Like

Ohhh, this might be it! Iā€™ll try it out, thank you!

UIDragDetector is expected to release sometime around the end of the month or early September, if you arenā€™t able to wait and need a project out immediately then use the resource I just sent.

1 Like

Hey, @1DiamondBor, thanks for raising this issue! I appreciate you bringing it to my attention. I just released a fix that should take care of the issue. Now, the UI should respect the boundaries correctly when dragged in any direction.

Just wanted to let you know that because of my college commitments, I might not be as quick to respond but I will do my best to handle any more concerns or issues.

Also, there may not be many modifications to this module given the upcoming availability of UIDragDetector. Still, Iā€™m happy it was useful, and Iā€™ll make sure any important matters are taken care of.

1 Like