OSRS Plugin API
    Preparing search index...

    Interface WindowHolder

    A container element that renders any windows attached to it. Instantiated internally only.

    interface WindowHolder {
        style: StyleTable;
        visible: boolean;
        addChild(obj: UiPrimitive): void;
        child(index: number): UiPrimitive;
        childCount(): number;
        insertChild(index: number, obj: UiPrimitive): void;
        removeChild(obj: UiPrimitive): boolean;
        removeChildAt(index: number): boolean;
    }

    Hierarchy (View Summary)

    Index

    Properties

    style: StyleTable

    The style, if any, that should be applied to this element.

    visible: boolean

    Determins if the container is visible or not.

    true
    
    -- 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)

    Methods

    • Adds an ImGUI element to the container.

      Parameters

      Returns void

      -- Create new container
      local newWindow = osrs.Ui.window({title = "Example Window"})

      -- Add new button to container
      newWindow:addChild(osrs.Ui.textButton({text = "test"}))

      -- Add container to the canvas
      osrs.Ui.canvas:addChild(newWindow)
    • Retrieves the ImGUI element at the specified index.

      Parameters

      • index: number

        The index of the element to retrieve.

      Returns UiPrimitive

      -- 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.

      Returns number

      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.

      Parameters

      • index: number

        The index to insert the element at.

      • obj: UiPrimitive

        The element to insert.

      Returns void

      -- 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.

      Parameters

      Returns boolean

      -- 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.

      Parameters

      • index: number

        The index of the element to remove.

      Returns boolean

      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)