API
Functions¶
getIcons¶
local icons = Icon.getIcons()
getIcon¶
local icon = Icon.getIcon(nameOrUID)
setTopbarEnabled¶
Icon.setTopbarEnabled(bool)
false
all TopbarPlus ScreenGuis are hidden. This does not impact Roblox's Topbar.
modifyBaseTheme¶
Icon.modifyBaseTheme(modifications)
setDisplayOrder¶
Icon.setDisplayOrder(integer)
Constructors¶
new¶
local icon = Icon.new()
32x32
icon on the topbar.
Methods¶
setName¶
{chainable}
icon:set(name)
Icon.getIcon(name)
.
getInstance¶
local instance = icon:getInstance(instanceName)
instanceName
.
modifyTheme¶
{chainable}
icon:modifyTheme(modifications)
modifyChildTheme¶
{chainable}
icon:modifyChildTheme(modifications)
setEnabled¶
{chainable}
icon:setEnabled(bool)
false
the icon will be disabled and hidden.
select¶
{chainable}
icon:select()
deselect¶
{chainable}
icon:deselect()
notify¶
{chainable}
icon:notify(clearNoticeEvent)
clearNotices¶
{chainable}
icon:clearNotices()
disableOverlay¶
{chainable}
icon:disableStateOverlay(bool)
true
, disables the shade effect which appears when the icon is pressed and released.
setImage¶
{chainable} {toggleable}
icon:setImage(imageId, iconState)
imageId
. imageId
can be an assetId or a complete asset string.
setLabel¶
{chainable} {toggleable}
icon:setLabel(text, iconState)
setOrder¶
{chainable} {toggleable}
icon:setOrder(order, iconState)
setCornerRadius¶
{chainable} {toggleable}
icon:setCornerRadius(scale, offset, iconState)
align¶
{chainable}
icon:align(alignment)
"Left"
(default), "Center"
or "Right"
side of the screen. See alignments for more details.
setWidth¶
{chainable} {toggleable}
icon:setWidth(minimumSize, iconState)
44
.
setImageScale¶
{chainable} {toggleable}
icon:setImageScale(number, iconState)
0.5
.
setImageRatio¶
{chainable} {toggleable}
icon:setImageRatio(number, iconState)
1
(a perfect square).
setTextSize¶
{chainable} {toggleable}
icon:setTextSize(number, iconState)
16
.
setTextFont¶
{chainable} {toggleable}
icon:setTextFont(font, fontWeight, fontStyle, iconState)
font
can be a font family name (such as "Creepster"
), a font enum (such as Enum.Font.Bangers
), a font ID (such as 12187370928
) or font family link (such as "rbxasset://fonts/families/Sarpanch.json"
).
bindToggleItem¶
{chainable}
icon:bindToggleItem(guiObjectOrLayerCollector)
unbindToggleItem¶
{chainable}
icon:unbindToggleItem(guiObjectOrLayerCollector)
bindEvent¶
{chainable}
icon:bindEvent(iconEventName, callback)
iconEventName
. It's important to remember all event names are in camelCase. callback
is called with arguments (self, ...)
when the event is triggered.
unbindEvent¶
{chainable}
icon:unbindEvent(iconEventName)
iconEventName
.
bindToggleKey¶
{chainable}
icon:bindToggleKey(keyCodeEnum)
unbindToggleKey¶
{chainable}
icon:unbindToggleKey(keyCodeEnum)
call¶
{chainable}
icon:call(func)
task.spawn
. The first argument passed is the icon itself. This is useful when needing to extend the behaviour of an icon while remaining in the chain.
addToJanitor¶
{chainable}
icon:addToJanitor(userdata)
lock¶
{chainable}
icon:lock()
icon:select()
.
unlock¶
{chainable}
icon:unlock()
debounce¶
{chainable} {yields}
icon:debounce(seconds)
icon:lock() task.wait(seconds) icon:unlock()
. This is useful for applying cooldowns (to prevent an icon from being pressed again) after an icon has been selected or deselected.
autoDeselect¶
{chainable}
icon:autoDeselect(true)
true
(the default) the icon is deselected when another icon (with autoDeselect enabled) is pressed. Set to false
to prevent the icon being deselected when another icon is selected (a useful behaviour in dropdowns).
oneClick¶
{chainable}
icon:oneClick(bool)
setCaption¶
{chainable}
icon:setCaption(text)
nil
as text
. See captions for more details.
setCaptionHint¶
{chainable}
icon:setCaptionHint(keyCodeEnum)
icon:bindToggleKey
.
setDropdown¶
{chainable}
icon:setDropdown(arrayOfIcons)
table array
of icons
. Pass an empty table {}
to remove the dropdown. See dropdowns for more details.
joinDropdown¶
{chainable}
icon:joinDropdown(parentIcon)
parentIcon
. This is what icon:setDropdown
calls internally on the icons within its array.
setMenu¶
{chainable}
icon:setMenu(arrayOfIcons)
{}
to remove the menu. See menus for more details.
joinMenu¶
{chainable}
icon:joinMenu(parentIcon)
parentIcon
. This is what icon:setMenu
calls internally on the icons within its array.
leave¶
{chainable}
icon:leave()
destroy¶
{chainable}
icon:destroy()
Events¶
selected¶
icon.selected:Connect(function(fromSource)
-- fromSource can be useful for checking if the behaviour was triggered by a user (such as clicking)
-- fromSource values include "User", "OneClick", "AutoDeselect", "HideParentFeature", "Overflow"
local sourceName = fromSource or "Unknown"
print("The icon was selected by the "..sourceName)
end)
deselected¶
icon.deselected:Connect(function(fromSource)
local sourceName = fromSource or "Unknown"
print("The icon was deselected by the "..sourceName)
end)
toggled¶
icon.toggled:Connect(function(isSelected, fromSource)
local stateName = (isSelected and "selected") or "deselected"
print(`The icon was {stateName}!`)
end)
viewingStarted¶
icon.viewingStarted:Connect(function()
print("A mouse, long-pressed finger or gamepad selection is hovering over the icon")
end)
viewingEnded¶
icon.viewingEnded:Connect(function()
print("The input is no longer viewing (hovering over) the icon")
end)
notified¶
icon.notified:Connect(function()
print("New notice")
end)
Properties¶
name¶
{read-only}
local string = icon.name --[default: "Widget"]
isSelected¶
{read-only}
local bool = icon.isSelected
enabled¶
{read-only}
local bool = icon.enabled
totalNotices¶
{read-only}
local int = icon.totalNotices
locked¶
{read-only}
local bool = icon.locked