The current state of the collapsing header (Header is open if true)
-- Create new container
local newWindow = osrs.Ui.window({title = "Example Window"})
-- Create a collapsing header that is closed, and one that is open
local closedCollapsingHeader = osrs.Ui.collapsingHeader({text = "Closed"})
local openCollapsingHeader = osrs.Ui.collapsingHeader({text = "Open", openState = true})
-- Create a button and add it to the headers
closedCollapsingHeader:addChild(osrs.Ui.textButton({text = "Button"}))
openCollapsingHeader:addChild(osrs.Ui.textButton({text = "Button"}))
-- Add collapsing headers to the container
newWindow:addChild(closedCollapsingHeader)
newWindow:addChild(openCollapsingHeader)
-- Add container to the canvas
osrs.Ui.canvas:addChild(newWindow)
How this element should position itself.
-- Create a window that has automatic position mode, this is default
local window1 = osrs.Ui.window({title = "Automatic Position Mode"})
-- Create a window that has manual position mode
local window2 = osrs.Ui.window(
{
title = "Manual Position Mode",
positionMode = osrs.Ui.LayoutMode.MANUAL
}
)
-- Add the windows to the canvas
osrs.Ui.canvas:addChild(window1)
osrs.Ui.canvas:addChild(window2)
Flag to control whether this element should be placed on the same line as the previous element.
-- Create a container
local window = osrs.Ui.window({title = "Example Window"})
-- Create three buttons, with two of them on the same line
local button1 = osrs.Ui.textButton({text = "Button 1"})
local button2 = osrs.Ui.textButton({text = "Button 2"})
local button3 = osrs.Ui.textButton({text = "Button 3", sameLine = true})
-- Add buttons to the container
window:addChild(button1)
window:addChild(button2)
window:addChild(button3)
-- Add container to the canvas
osrs.Ui.canvas:addChild(window)
The style, if any, that should be applied to this element.
The text to display in the header.
-- Create new container
local newWindow = osrs.Ui.window({title = "Example Window"})
-- Create a collapsing header with text
local collapsingHeader = osrs.Ui.collapsingHeader({text = "Test"})
-- Create a button and add it to the collapsing header
collapsingHeader:addChild(osrs.Ui.textButton({text = "Button"}))
-- Add collapsing header to the container
newWindow:addChild(collapsingHeader)
-- Add container to the canvas
osrs.Ui.canvas:addChild(newWindow)
String to display to the user when hovered over the element.
-- Create new container
local newWindow = osrs.Ui.window({title = "Example Window"})
-- Create a button with a tooltip
local button = osrs.Ui.textButton({text = "Test", tooltip = "This is a Tooltip!"})
-- Add slider to the container
newWindow:addChild(button)
-- Add container to the canvas
osrs.Ui.canvas:addChild(newWindow)
Determins if the container is visible or not.
-- Create new container that is visible
local visibleWindow = osrs.Ui.window({title = "Visible Window"})
-- Create new container that is not visible
local notVisibleWindow = osrs.Ui.window({title = "Not visible Window", visible = false})
-- Add the containers to the canvas
osrs.Ui.canvas:addChild(visibleWindow)
osrs.Ui.canvas:addChild(notVisibleWindow)
The horizontal component of this element's position, in UI coordinate space.
The percentage distance from the left side of the screen that this element's top-left corner should be placed at when positionMode is set to LayoutMode.PROPORTIONAL. The number needs to be a decimal.
The vertical component of this element's position, in UI coordinate space.
The percentage distance from the top side of the screen that this element's top-left corner should be placed at when positionMode is set to LayoutMode.PROPORTIONAL. The number needs to be a decimal.
Adds an ImGUI element to the container.
The element to insert.
Adds a UI element to the pop up container.
Imgui element to add to the pop up menu
local button = osrs.Ui.textButton( { text="Clear", tooltip="Test" })
local selectable = osrs.Ui.selectable({text = "Example", onClick = function() osrs.print("Example Print") end}) clear:addPopUpElement(test) osrs.Ui.leftPanel:addChild(button)
Retrieves the ImGUI element at the specified index.
The index of the element to retrieve.
-- Create new container
local newWindow = osrs.Ui.window({title="Example Window"})
-- Add a button to the container
newWindow:addChild(osrs.Ui.textButton({text = "test"}))
-- Set the example button as the button in the container
local exampleButton = newWindow:child(0)
-- See how the example button has the same text as the container button
if exampleButton.text == "test" then
osrs.print("Example button coppied correctly")
end
Returns the number of elements in the container.
the number of childen in the container.
-- Create new container
local newWindow = osrs.Ui.window({title="Example Window"})
-- Add two buttons to the container
newWindow:addChild(osrs.Ui.textButton({text = "Button 1"}))
newWindow:addChild(osrs.Ui.textButton({text = "Button 2"}))
-- Print how many elements are in the container
osrs.print(tostring(newWindow:childCount()))
Inserts an ImGUI element to the container to the specified index. If the size of the ImGUI list is smaller, it will be inseted at the end.
The index to insert the element at.
The element to insert.
-- Create new container
local newWindow = osrs.Ui.window({title="Example Window"})
-- Inserts a button to index 2 of the container
newWindow:insertChild(2, osrs.Ui.textButton({text = "Button 1"}))
-- See how the button gets moved to the end of the ImGUI list
if newWindow:child(0).text == "Button 1" and newWindow:child(2) == nil then
osrs.print("Button 1 added to end of ImGUI list")
end
-- Inserts a button to index 0 of the container
newWindow:insertChild(0, osrs.Ui.textButton({text = "Button 2"}))
-- See how Button 2 button gets added at index 0 and Button 1 button gets moved to index 1
if newWindow:child(0).text == "Button 2" and newWindow:child(1).text == "Button 1" then
osrs.print("Button 2 added to index 0, Button 1 moved to index 1")
end
-- Add container to the canvas
osrs.Ui.canvas:addChild(newWindow)
Removes the first instance of the specified ImGUI element in the container. No-op if not in element not present in container.
The element to remove.
-- Create new container
local newWindow = osrs.Ui.window({title="Example Window"})
-- Add two buttons to the container
newWindow:addChild(osrs.Ui.textButton({text = "Button 1"}))
newWindow:addChild(osrs.Ui.textButton({text = "Button 2"}))
-- Set the example button as the first button in the container
local exampleButton = newWindow:child(0)
-- Remove the first button
newWindow:removeChild(exampleButton)
-- Add container to canvas and see how Button 2 is the only button in the container
osrs.Ui.canvas:addChild(newWindow)
Removes the element at the specified index in the container. Returns false if index is not present in container.
The index of the element to remove.
boolean indicating success of removal.
-- Create new container
local newWindow = osrs.Ui.window({title="Example Window"})
-- Add two buttons to the container
newWindow:addChild(osrs.Ui.textButton({text = "Button 1"}))
newWindow:addChild(osrs.Ui.textButton({text = "Button 2"}))
-- Remove the first button
newWindow:removeChildAt(0, exampleButton)
-- Add container to canvas and see how Button 2 is the only button in the container
osrs.Ui.canvas:addChild(newWindow)
Removes a UI element from the pop up container.
Imgui element to remove from the pop up menu.
local button = osrs.Ui.textButton( { text="Clear", tooltip="Test" })
local selectable = osrs.Ui.selectable({text = "Example", onClick = function() osrs.print("Example Print") end}) clear:addPopUpElement(test) clear:removePopUpElement(test) osrs.Ui.leftPanel:addChild(button)
A header+container that can be toggled to hide its elements.