Droppable DModelPanel

Been wondering how I can go about doing this with the “droppable” and “receiver” functions.

??? What’re you trying to say here?

EDIT: O, you mean the Panel:Droppable() and Panel:Receiver()

Alright, so on the panel you want to drop, I assume your DModelPanel, you need to do


DmodelPanel:Droppable("UniqueIdentifier"). 


Then, on the panel you want to be able to receive the DModelPanel, you must do


thePanel:Receiver("Unique_Identifier_That_You_Used_For_The_Droppable_Function", function(Table_Of_The_Receiver_Panel, Panels_Dropped, WasDroppedOrHoveredBoolean, IndexOfItem, CursorPosX, CursorPosY))


This is much better explained here.

I understand how it works but when adding the Droppable function doesn’t work on DModelPanel. I’m asking if there is a workaroud or a correct way to make it work.

These do work, these are both for creating a ‘drag’n’drop’ bases tile you could say.

They do work. Can we see your code to see if you did something wrong?

Here is the code I’m using ATM. It is trimmed a bit but should provide enough info


function PANEL:Update()
	for i = 1, 35 do
		local bgCol = Color(10, 10, 10, 255)
		self.backgroundPanel = self.panelList:Add("DPanel")
		self.backgroundPanel:SetSize(64, 64)
		self.backgroundPanel.Slot = i

		self.backgroundPanel.Paint = function(self, w, h)
			draw.RoundedBox(0, 0, 0, self:GetWide(), self:GetTall(), bgCol)
			draw.RoundedBox(0, 1, 1, self:GetWide() - 2, self:GetTall() - 2, Color(100, 100, 100, 200))
		end

		self.backgroundPanel:Receiver( "invItem", function( receiver, tableOfDroppedPanels, isDropped, menuIndex, mouseX, mouseY )
			print(receiver.Slot)
		end, {} )

		for k, v in pairs(Inventory) do
			if v[2] == i then
				local itemTable = SGMRP.Inventory.Items:GetItem(v[1])
				self.Icon = vgui.Create("DModelPanel", self.backgroundPanel)
				self.Icon:SetSize(64, 64)
				self.Icon:SetModel(itemTable.Model)
				self.Icon:SetTooltip("Name: " .. itemTable.Name .. "
Info: " .. itemTable.Info .. "
Count: " .. v[3])

				local mn, mx = self.Icon.Entity:GetRenderBounds()
				local size = 0
				size = math.max(size, math.abs(mn.x) + math.abs(mx.x))
				size = math.max(size, math.abs(mn.y) + math.abs(mx.y))
				size = math.max(size, math.abs(mn.z) + math.abs(mx.z))

				self.Icon:SetFOV(45)
				self.Icon:SetCamPos(Vector(size, size, size))
				self.Icon:SetLookAt((mn + mx) * 0.5)

				function self.Icon:LayoutEntity(Entity)
					self:RunAnimation()
				end

				self.Icon.DoClick = function()
					local Menu = DermaMenu()

					if itemTable.dropAble == 1 then
						Menu:AddOption("Drop", function()
							LocalPlayer():ConCommand("ia_item_drop " .. k)
							ToggleMenu()
						end)
					end

					if itemTable.useAble == 1 then
						Menu:AddOption("Use", function()
							LocalPlayer():ConCommand("ia_item_use " .. k)
							ToggleMenu()
						end)
					end

					Menu:Open()
				end

				self.Icon.OnCursorEntered = function()
					bgCol = Color(80, 80, 80, 255)
				end

				self.Icon.OnCursorExited = function()
					bgCol = Color(10, 10, 10, 255)
				end

				self.Icon:Droppable("invItem")
			end
		end
	end
end

[editline]20th September 2017[/editline]

I should add that it can be dragged and dropped, but the DModelPanel isn’t being dragged as it should be.

I’ve switched to SpawnIcon instead. Solved