Garry's Mod Wiki

Panel:SetDragParent

Panel:SetDragParent( Panel parent )

Description

Sets the drag parent.

Drag parent means that when we start to drag this panel, we'll really start dragging the defined parent.

Arguments

1 Panel parent
The panel to set as drag parent.

Example

local function DoDrop( self, panels, bDoDrop, Command, x, y ) if ( bDoDrop ) then for _, v in ipairs( panels ) do self:AddItem( v ) end end end concommand.Add( "test2", function() local frame = vgui.Create( "DFrame" ) frame:SetSize( 500, 300 ) frame:SetTitle( "Frame" ) frame:MakePopup() frame:Center() local left = vgui.Create( "DScrollPanel", frame ) left:Dock( LEFT ) left:SetWidth( frame:GetWide() / 2 - 7 ) left:SetPaintBackground( true ) left:DockMargin( 0, 0, 4, 0 ) left:Receiver( "myDNDname", DoDrop ) -- Make the panel a receiver for drag and drop events local right = vgui.Create( "DScrollPanel", frame ) right:Dock( FILL ) right:SetPaintBackground( true ) right:Receiver( "myDNDname", DoDrop ) for i = 1, 30 do local but = vgui.Create( "DButton" ) but:SetText( "button text " .. i ) but:SetSize( 36, 24 ) but:Dock( TOP ) but:Droppable( "myDNDname" ) -- make the panel be able to be drag'n'dropped onto other panels right:AddItem( but ) local mdl = vgui.Create( "DModelPanel", but ) -- Put another panel over the draggable button mdl:Dock( FILL ) mdl:SetModel( "models/alyx.mdl" ) mdl:SetDragParent( but ) -- The magic bit. Without it, you would not be able to drag the button at all end end )

Page Links


Special Pages


Wikis

?

Render Time: 78ms

DB GetPage 41
Generate Html 11
SaveChanges (1) 10
Render Body 0
Render Sidebar 13