Garry's Mod Wiki

DDragBase

Description

This is used internally - although you're able to use it you probably shouldn't.

A VGUI base panel providing drag/drop functionality. Used by DIconLayout, DListLayout and DTileLayout.

View source

Parent

Derives methods, etc not listed on this page from DPanel.

Implements

Implements or overrides the following hooks/methods. If you want to override these, you probably want to call the original function too.

Events

DDragBase:OnModified()
Called when anything is dropped on or rearranged within the DDragBase.

Methods

DDragBase:DropAction_Copy( table drops, boolean bDoDrop, string command, number y, number x )
This is used internally - although you're able to use it you probably shouldn't. Internal function used in DDragBase:MakeDroppable
DDragBase:DropAction_Normal( table drops, boolean bDoDrop, string command, number y, number x )
This is used internally - although you're able to use it you probably shouldn't. Internal function used in DDragBase:DropAction_Copy
DDragBase:DropAction_Simple( table drops, boolean bDoDrop, string command, number y, number x )
This is used internally - although you're able to use it you probably shouldn't. Internal function used in DDragBase:DropAction_Normal
string DDragBase:GetDnD()
Returns the drag'n'drop group this panel belongs to. See DDragBase:MakeDroppable.
boolean DDragBase:GetReadOnly()
Returns whether this panel is read only or not for drag'n'drop purposes.
Whether this panel uses live drag'n'drop previews.
DDragBase:MakeDroppable( string name, boolean allowCopy )
Makes the panel a receiver for any droppable panel with the same DnD name. Internally calls Panel:Receiver. See Drag and Drop for VGUI.
DDragBase:SetDnD( string name )
This is used internally - although you're able to use it you probably shouldn't. Used internally by DDragBase:MakeDroppable.
DDragBase:SetDropPos( string pos = "5" )
Determines where you can drop stuff. "4" for left "5" for center "6" for right "8" for top "2" for bottom
DDragBase:SetReadOnly( boolean name )
Sets whether this panel is read only or not for drag'n'drop purposes. If set to true, you can only copy from this panel, and cannot modify its contents.
DDragBase:SetUseLiveDrag( boolean newState )
Whether to use live drag'n'drop previews.
DDragBase:UpdateDropTarget( number drop, Panel pnl )
This is used internally - although you're able to use it you probably shouldn't. Internal function used in DDragBase:DropAction_Normal

Example

local frame = vgui.Create( "DFrame" ) frame:SetSize( 300, 500 ) frame:Center() frame:MakePopup() local dragbase = vgui.Create( "DDragBase", frame ) dragbase:Dock( FILL ) dragbase:MakeDroppable( "test" ) dragbase:SetDropPos( "82" ) for i = 0, 10 do local butt = dragbase:Add( "DButton" ) --butt:Dock( TOP ) butt:SetPos( 25, i * 25 ) butt:SetWidth( 100 ) butt:Droppable( "test" ) butt.id = i butt.Think = function( s ) s:SetText( "ID: " .. i .. " ZPOS: " .. s:GetZPos() ) end end