CreateScrollingFrame (Function): Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
>JulienDethurens
No edit summary
m Text replacement - "</SyntaxHighlight>" to "</syntaxhighlight>"
 
(12 intermediate revisions by 3 users not shown)
Line 1: Line 1:
<onlyinclude>
<onlyinclude>
{{User:JulienDethurens/Sandbox|name = CreateScrollingFrame
{{Function
|arguments  = [[table]] '''orderList''', [[string]] '''style'''
|name = CreateScrollingFrame
|returns    = [[Frame]] ''scrollFrame'', [[ImageButton]] ''scrollUpButton'', [[ImageButton]] ''scrollDownButton'', [[function]] ''recalculateFunction''
|arguments  = [[table]] <var>orderList</var>, [[string]] <var>style</var>
|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).
|returns    = [[RBX.lua.Frame (Object)|Frame]] <var>scrollFrame</var>, [[RBX.lua.ImageButton (Object)|ImageButton]] <var>scrollUpButton</var>, [[RBX.lua.ImageButton (Object)|ImageButton]] <var>scrollDownButton</var>, [[function]] <var>recalculateFunction</var>
|library      = RbxGui
|description =  Returns 4 objects, (<var>scrollFrame</var>, <var>scrollUpButton</var>, <var>scrollDownButton</var>, <var>recalculateFunction</var>).  <var>scrollFrame</var> can be filled with [[RBX.lua.GuiObject (Object)|GuiObjects]].  It will lay them out and allow scrollUpButton/scrollDownButton to interact with them.  <var>orderList</var> is an <strong>optional</strong> argument (and specifies the order to layout the children.  Without orderlist, it uses the children order) style is also <strong>optional</strong>, and allows for a 'grid' styling if style is passed 'grid' as a string.  <var>recalculateFunction</var> can be called when a relayout is needed (when <var>orderList</var> changes, or when <var>scrollFrame</var> size changes).
}}
}}


Line 32: Line 32:
scrollUp.Parent = scroller
scrollUp.Parent = scroller
scrollDown.Parent = scroller
scrollDown.Parent = scroller
</code></td><td>[[Image:GearScrollingFrame.jpg|thumb|250px|CreateScrollingFrame Example]]</td></tr></table>
</syntaxhighlight></td><td>[[Image:GearScrollingFrame.jpg|thumb|250px|CreateScrollingFrame Example]]</td></tr></table>
 
==See Also==
*[[RbxGui (Library)|RbxGui]]
 
[[Category:Functions]]

Latest revision as of 04:57, 27 April 2023

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