Garry's Mod Wiki
Drag 'N' Drop
This is a drag n drop tutorial since it's barely documented. It's very easy, all you need to have is two panels: a receiver and a droppable panel.
How it Works
Panel:Droppable( string name ) takes 1 argument:
- Name - Must match receiver's name to allow dropping
Panel:Receiver( string name, function callback, table menu = nil ) takes 3 arguments:
- Name - Identifier to match droppable panels
- Callback - Function called when dragging/dropping occurs
- Menu Options - Table of strings for right-click menu (optional)
The callback receives:
- self - The receiving panel
- panels - Table of panels being dropped
- dropped - True when actually dropped, false while dragging over
- menuIndex - Index if using right-click menu
- x,y - Drop coordinates relative to receiver
In the example below:
- Red panel can only be dropped on right frame
- Green panel can be dropped on either frame
- When dropped, panels become children of the receiving frame
Basic Example
Here's a complete example showing one-way and two-way drag and drop:

This site is a community mirror of the official Garry's Mod wiki.. This site is not maintained by Facepunch Studios.
Page content is automatically updated four times a day. Edits and history are not available.
Last Parsed: Loading...