Skip to content

melon.elements

garryspins edited this page Feb 27, 2026 · 5 revisions

melon.elements


client link

Contains all PANEL objects added by the library
melon

Classes

melon.elements.Button

client link

Generic unstyled button


client link

melon.elements.Button:Click

client link
melon.elements.Button:Click(enum: MOUSE_, double?: bool)

Argument and Return information

Arguments

# Name Type Description
1 enum MOUSE_ What was the MOUSE_ enum of the click
2 double? bool Was this click a double click

Called on any click, dont override this unless you have to


client link

melon.elements.Button:RightClick

client link
melon.elements.Button:RightClick(double?: bool)

Argument and Return information

Arguments

# Name Type Description
1 double? bool Was this click a double click

Called on right click, override this.


client link

melon.elements.Button:LeftClick

client link
melon.elements.Button:LeftClick(double?: bool)

Argument and Return information

Arguments

# Name Type Description
1 double? bool Was this click a double click

Called on left click, override this.


client link

melon.elements.Button:CanClick

client link
melon.elements.Button:CanClick(enum: MOUSE_, double?: bool) -> bool?

Argument and Return information

Arguments

# Name Type Description
1 enum MOUSE_ What was the MOUSE_ enum of the click
2 double? bool Was this click a double click

Returns

# Name Type Description
1 can_click bool Should we fire the click event

Override this to determine whether or not to fire click events


client link

melon.elements.Button:OtherClick

client link
melon.elements.Button:OtherClick(enum: MOUSE_, double?: bool)

Argument and Return information

Arguments

# Name Type Description
1 enum MOUSE_ What was the MOUSE_ enum of the click
2 double? bool Was this click a double click

Called on any click that isnt right or left.

melon.elements.Draggable

client link

Draggable Panel object

local p = vgui.Create("DPanel")
p:SetSize(400, 400)
p:Center()
p:MakePopup()
p.drag = vgui.Create("Melon:Draggable", p)
p.drag:SetSize(200, 200)
p.drag:Center()
p.drag:SetAreaOf(p)  
local p = vgui.Create("DPanel")
p:SetSize(400, 400)
p:Center()
p:MakePopup()
p.drag = vgui.Create("Melon:Draggable", p)
p.drag:SetSize(200, 200)
p.drag:Center()
p.drag:SetAreaOf(p)  

Accessors

All of these values have Set*/Get* methods for them. They can also be indexed by their name, object.*

Name Type Comment
AreaOf panel Panel to drag when dragging this panel, think a topbar of a frame
Bounded panel Panel to limit the draggable area to, you can also pass true for the parent or false to disable

client link

melon.elements.Draggable:EndDragging

client link
melon.elements.Draggable:EndDragging()

Called when the panel stops being dragged, remember to invalidlink(SetCursor)


client link

melon.elements.Draggable:StartDragging

client link
melon.elements.Draggable:StartDragging()

Called when the panel starts being dragged, remember to invalidlink(SetCursor)

melon.elements.Mask

client link

A basepanel thats children render adheres to a mask


client link

melon.elements.Mask:Mask

client link
melon.elements.Mask:Mask(w: number, h: number)

Argument and Return information

Arguments

# Name Type Description
1 w number Width of the panel
2 h number Height of the panel

Called once per frame to determine the mask of the panel, override this


client link internal

melon.elements.Mask:PaintMaskRelative

client link internal
melon.elements.Mask:PaintMaskRelative()

Paints the mask texture relative to the given panel


client link

melon.elements.Mask:DoMask

client link
melon.elements.Mask:DoMask(pnl: Panel, w: number, h: number)

Argument and Return information

Arguments

# Name Type Description
1 pnl Panel Panel were rendering the mask of
2 w number Width of the panel
3 h number Height of the panel
Called when a mask render has been requested Override this if you wish to modify anything about how the mask is rendered, or use stacked masks Remember, call pnl.OldPaint and self:PaintMaskRelative

client link

melon.elements.Mask:MakeMask

client link
melon.elements.Mask:MakeMask(panel: panel)

Argument and Return information

Arguments

# Name Type Description
1 panel panel Panel to add to this mask
Adds a panel to this mask, must be called with no arguments in Init after child initialization And this must be called on all children when added IMPORTANT, This function overrides Paint and OnChildAdded

melon.elements.Resizable

client link

Resizable Panel object

local p = vgui.Create("Melon:Resizable")
p:SetSize(400, 400)
p:Center()
p:MakePopup()
p:SetMaxSize(600, 600)
p:SetMinSize(200, 200)  
local p = vgui.Create("Melon:Resizable")
p:SetSize(400, 400)
p:Center()
p:MakePopup()
p:SetMaxSize(600, 600)
p:SetMinSize(200, 200)  

client link

melon.elements.Resizable:SetMaxSize

client link
melon.elements.Resizable:SetMaxSize(w: number, h: number)

Argument and Return information

Arguments

# Name Type Description
1 w number Width of the max size
2 h number Height of the max size

Sets the maximum size for the panel to be resizable to


client link

melon.elements.Resizable:StartDragging

client link
melon.elements.Resizable:StartDragging()

Called when the panel starts being resized, remember to invalidlink(SetCursor)


client link internal

melon.elements.Resizable:WithinDragRegion

client link internal
melon.elements.Resizable:WithinDragRegion(x: number, y: number) -> bool?

Argument and Return information

Arguments

# Name Type Description
1 x number X to check
2 y number Y to check

Returns

# Name Type Description
1 is bool Is it within the draggable region

Check if a coord is within the drag region


client link

melon.elements.Resizable:AnimDone

client link
melon.elements.Resizable:AnimDone()

Called when the animation is done, if you replace Paint you need to call this by hand


client link

melon.elements.Resizable:SetDragSize

client link
melon.elements.Resizable:SetDragSize(size: number, pad: number)

Argument and Return information

Arguments

# Name Type Description
1 size number Size of the draggable area
2 pad number Padding from the edge of the draggable area

Sets the draggable corner size and padding


client link

melon.elements.Resizable:OnTabChanged

client link
melon.elements.Resizable:OnTabChanged(new: panel, old: panel)

Argument and Return information

Arguments

# Name Type Description
1 new panel New tab panel
2 old panel Old tab panel

Called when the tab is changed


client link

melon.elements.Resizable:EndDragging

client link
melon.elements.Resizable:EndDragging()

Called when the panel stops being resized, remember to invalidlink(SetCursor)


client link

melon.elements.Resizable:SetMinSize

client link
melon.elements.Resizable:SetMinSize(w: number, h: number)

Argument and Return information

Arguments

# Name Type Description
1 w number Width of the min size
2 h number Height of the min size

Sets the minimum size for the panel to be resizable to

melon.elements.ScrollBar

client link

Scrollbar for ScrollPanels, handles the actual scrolling logic

Accessors

All of these values have Set*/Get* methods for them. They can also be indexed by their name, object.*

Name Type Comment
ScrollAmount number Current scroll pos in pixels
Canvas Panel Current canvas panel
Horizontal boolean Is the scrollbar horizontal
OverflowAmount number How much is the scrollbar currently overflowing, negative if up
iRealScrollAmount number Internal, current real scroll position, interpolated
iGrabbed table Internal, grab data
iGripColor Color Internal, grip color
iPanning boolean Internal, are we panning

client link

melon.elements.ScrollBar:GetDomain

client link
melon.elements.ScrollBar:GetDomain() -> number

Argument and Return information

Returns

# Name Type Description
1 num number The domain

Returns the "Domain", the actual scrollable area of the canvas, so (canvas_size - parent_size)


client link internal

melon.elements.ScrollBar:Grab

client link internal
melon.elements.ScrollBar:Grab()

Initiates grip grabbing


client link

melon.elements.ScrollBar:ScrollTo

client link
melon.elements.ScrollBar:ScrollTo(pos: number)

Argument and Return information

Arguments

# Name Type Description
1 pos number Position to scroll to

Scrolls to the given coordinate, if horizontal than X, if vertical than Y


client link

melon.elements.ScrollBar:ScrollToChild

client link
melon.elements.ScrollBar:ScrollToChild(pnl: Panel)

Argument and Return information

Arguments

# Name Type Description
1 pnl Panel Panel to scroll to

Scrolls to a child panel, if the panel isnt a child then silently fails


client link

melon.elements.ScrollBar:AddScroll

client link
melon.elements.ScrollBar:AddScroll(delta: number, pixels?: number)

Argument and Return information

Arguments

# Name Type Description
1 delta number Scroll delta to add
2 pixels? number Optional, how many pixels to scroll instead of delta

Scrolls the scrollbar however much is specified

melon.elements.ScrollPanel

client link

A general purpose unstyled scrollpanel rewrite containing over-content scrollbars, smooth scrolling and canvas based scrolling.

Accessors

All of these values have Set*/Get* methods for them. They can also be indexed by their name, object.*

Name Type Comment
ScrollPerDelta number How many pixels to scroll per-scroll wheel delta, unscaled
ScrollbarSize number How wide should the scrollbars be
ScrollbarPad number How much padding should the scrollbars have
ScrollbarMaxOverflow number How much overflow in pixels should we allocate to the scrollbars, unscaled
PanningEnabled boolean Should we allow panning on the scrollbars with middle mouse button note you need to call :Pan() yourself
Canvas Panel Canvas panel
VerticalScrollEnabled boolean Should we allow vertical scrolling
HorizontalScrollEnabled boolean Should we allow horizontal scrolling

client link

melon.elements.ScrollPanel:Pan

client link
melon.elements.ScrollPanel:Pan()
Start panning, should only be called while MOUSE_MIDDLE is down Automatically abides by the PanningEnabled accessor

melon.elements.Tabs

client link

Handles multiple tabs, think DPropertySheet without the visuals and builtin handling

Accessors

All of these values have Set*/Get* methods for them. They can also be indexed by their name, object.*

Name Type Comment
ActiveTab any Active tab keyname
AnimTime number Animation time
InitialTab any First tab keyname

client link

melon.elements.Tabs:SetTab

client link
melon.elements.Tabs:SetTab(name: string)

Argument and Return information

Arguments

# Name Type Description
1 name string Name of the tab to set

Sets the current tab to the given tab, animates!


client link

melon.elements.Tabs:SetTabPending

client link
melon.elements.Tabs:SetTabPending(name: string)

Argument and Return information

Arguments

# Name Type Description
1 name string Name of the tab to set

Sets the current tab to the given tab on the next tick


client link internal

melon.elements.Tabs:Paint

client link internal
melon.elements.Tabs:Paint()

Handles applying animation progress, read the source before replacing the Paint of this, Paint the parent instead


client link

melon.elements.Tabs:AddFutureTab

client link
melon.elements.Tabs:AddFutureTab(name: any, fn(name: self) -> Panel)

Argument and Return information

Arguments

# Name Type Description
1 name any Identifier for the tab
2 fn fn(name: self) -> Panel Function to run to generate the tab

Adds a tab that will be generated when the tab gets switched to


client link internal

melon.elements.Tabs:Think

client link internal
melon.elements.Tabs:Think()

Handles animation progress stuff, dont touch, if you do touch replace it


client link

melon.elements.Tabs:AddTab

client link
melon.elements.Tabs:AddTab(name: any, panel: Panel) -> Panel

Argument and Return information

Arguments

# Name Type Description
1 name any Keyname for the tab
2 panel Panel Valid Panel to add to the tab handler

Returns

# Name Type Description
1 added Panel Panel that was added

Adds the given panel as a tab with the name given to the handler

Panels

Melon:RichText

client link

A RichText renderer and layout system

[!NOTE]
This is a Panel, it can be created using vgui.Create("Melon:RichText"). Its PANEL metatable can be accessed with melon.elements.RichText

Accessors

All of these values have Set*/Get* methods for them. They can also be indexed by their name, object.*

Name Type Comment
Color Color Color of the tetx
Font string Font of the text
Underline number Should the text be underlined If so, how far should it be from the text baseline, scaled.
Strikethrough bool Should the text be struck through
Interactable fn Function to run on text click
Custom fn Function to run instead of rendering the text

Melon:TextEntry

client link

Wrapper Panel to allow use of raw TextEntry's without painful manual

[!NOTE]
This is a Panel, it can be created using vgui.Create("Melon:TextEntry"). Its PANEL metatable can be accessed with melon.elements.TextEntry

Clone this wiki locally