Draggable GUI Elements Module

What did you do to fix the issue? I have just implemented the module and everything is working fine except for the release event which is triggered every time to GUI is moved rather then when released.

2 Likes

To add to the above, I have done more testing and it seems that any event I bind to is triggered by every event for every draggable object. That is to say, when the ā€˜Startedā€™ event fires by one draggable object, every event connection receives a signal from the ā€˜Startedā€™, "Movedā€™ and ā€˜Releasedā€™ eventā€¦ for every draggable object that exists.

I had 16 draggable objects created during this test. Each object was binded to the 3 events that should only exist for that specific object:
image

image

image

Is there something Iā€™m missing here? Is this a problem with the Remote module? On that topic I am curious why the Remote module is even neededā€¦ whatā€™s wrong with just using Bindable events?

1 Like

Switching out usage of the Remote module with BindableEvents has fixed the problem so Iā€™m fairly confident there is some issue with the Remote module.

1 Like

Hey, sorry for the slight bump, but every time I call :Destroy() on the draggable class, i get this error

hereā€™s my code:

local CurrentDraggable

local function OpenUI()
	Gui.Enabled = true
	AppearTween:Play()

	CurrentDraggable = DraggableUI.new(MainFrame)
	CurrentDraggable:Ignore(IgnoreObjects) -- Allow the frame to be draggable
end

-- Main

-- Set ignored objects for UI
for i, Object in pairs(MainFrame:GetDescendants()) do
	if Object:IsA("TextBox") or Object:IsA("GuiButton") or Object:IsA("ScrollingFrame") then
		table.insert(IgnoreObjects, Object)
	end
end

CloseButton.MouseButton1Click:Connect(function()
	MainFrame.GroupTransparency = 1
	Gui.Enabled = false
	
	CurrentDraggable:Destroy()
end)

MainFrame.GroupTransparency = 1

OpenUI()

OpenUIEvent.OnClientEvent:Connect(function(GuiName)
	if Gui.Name == GuiName then
		OpenUI()
	end
end)
1 Like

Thank you so much for this, actual life saver.

1 Like

Why is this not fixed yet? Can you update?

3 Likes

I just updated the module, but it is completely different. Some of the features that were in the previous module are no longer in the current module, but I do plan on adding them back in the future.

3 Likes

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