CreateScrollingFrame (Function)

From Legacy Roblox Wiki
(Redirected from CreateScrollingFrame)
Jump to navigationJump to search
CreateScrollingFrame( table orderList, string style )
Returns Frame scrollFrame, ImageButton scrollUpButton, ImageButton scrollDownButton, function recalculateFunction
Description: Returns 4 objects, (scrollFrame, scrollUpButton, scrollDownButton, recalculateFunction). scrollFrame can be filled with GuiObjects. It will lay them out and allow scrollUpButton/scrollDownButton to interact with them. orderList is an optional argument (and specifies the order to layout the children. Without orderlist, it uses the children order) style is also optional, and allows for a 'grid' styling if style is passed 'grid' as a string. recalculateFunction can be called when a relayout is needed (when orderList changes, or when scrollFrame size changes).



The code below is used in the current backpack, and allows gear to be shown in a 2d grid style that the user can scroll through if the gear takes up more room than the frame allows. local scrollFrame, scrollUp, scrollDown, recalculateScroll = RbxGui.CreateScrollingFrame(nil,"grid")

scrollFrame.Position = UDim2.new(0,0,0,30) scrollFrame.Size = UDim2.new(1,0,1,-30) scrollFrame.Parent = backpack.GearGrid

local scrollBar = Instance.new("Frame") scrollBar.Name = "Scrolling" scrollBar.BackgroundTransparency = 0.9 scrollBar.BackgroundColor3 = Color3.new(1,1,1) scrollBar.BorderSizePixel = 0 scrollBar.Size = UDim2.new(0, 17, 1, -36) scrollBar.Position = UDim2.new(0,0,0,18) scrollBar.Parent = scroller

scrollDown.Position = UDim2.new(0,0,1,-17)

scrollUp.Parent = scroller scrollDown.Parent = scroller

</syntaxhighlight>
CreateScrollingFrame Example

See Also