CCKit2
    Preparing search index...

    Class CCOutlineView<Item>

    An outline view is a type of table which displays hierarchical data in groups which can be expanded and collapsed.
    Example image

    TypeScript
    class DataSource implements CCOutlineViewDataSource<[any, any]> {
    private root: any;
    constructor(root: any) {
    this.root = root;
    }
    numberOfColumns(outlineView: CCOutlineView<[any, any]>): number {
    return 1;
    }
    numberOfChildrenOfItem(outlineView: CCOutlineView<[any, any]>, item?: [any, any]): number {
    let value: any;
    if (item === undefined) item = this.root;
    else value = item[1];
    if (type(value) !== "table") return -1;
    let count = 0;
    for (let [k, v] of pairs(value as LuaTable)) count++;
    return count;
    }
    childOfItem(outlineView: CCOutlineView<[any, any]>, index: number, parent?: [any, any]): [any, any] {
    let value: any;
    if (parent === undefined) value = this.root;
    else value = parent[1];
    let [k, v] = next(value);
    while (index > 0) {
    index--;
    [k, v] = next(value, k);
    }
    return [k, v];
    }
    viewForItemAtColumn(outlineView: CCOutlineView<[any, any]>, item: [any, any], column: number): CCView {
    return new CCLabel({x: 1, y: 1}, tostring(item[0]));
    }
    }

    let outlineView = new CCOutlineView({x: 1, y: 1, width: 40, height: 15}, new DataSource(someTable));
    this.view.addSubview(outlineView);
    Lua
    local DataSource = {}
    function DataSource:____constructor(root)
    self.root = root
    end
    function DataSource:numberOfColumns(outlineView)
    return 1
    end
    function DataSource:numberOfChildrenOfItem(outlineView, item)
    local value
    if item == nil then item = self.root
    else value = item[2] end
    if type(value) ~= "table" then return -1 end
    local count = 0
    for k, v of pairs(value) do count = count + 1 end
    return count
    end
    function DataSource:childOfItem(outlineView, index, parent)
    local value
    if parent == nil then value = self.root
    else value = parent[2] end
    local k, v = next(value);
    while index > 0 do
    index = index - 1
    k, v = next(value, k)
    end
    return {k, v}
    end
    function DataSource:viewForItemAtColumn(outlineView, item, column)
    return LuaWrappers.new(CCLabel, {x = 1, y = 1}, tostring(item[1]))
    end
    DataSource = LuaWrappers.class("DataSource", nil, DataSource)

    local outlineView = LuaWrappers.new(CCOutlineView, {x = 1, y = 1, width = 40, height = 15}, LuaWrappers.new(DataSource, someTable))
    self.view:addSubview(outlineView)

    Type Parameters

    • Item extends AnyNotNil

      Type of object that the data source provides

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    acceptsFirstResponder: boolean = true

    Whether the object can become the first responder.

    canSelectMultipleRows: boolean = false

    Whether multiple rows can be selected.

    canSelectRow: boolean = false

    Whether a row can be selected.

    The object which receives events such as selections.

    isFocused: boolean = false

    Whether the view is currently focused.

    isHidden: boolean = false

    Whether the view is hidden.

    needsDraw: boolean = true

    Whether the view needs to be redrawn.

    needsLayout: boolean = false

    Whether the view needs to be laid out.

    needsUpdateConstraints: boolean = false

    Whether constraints need to be updated.

    nextResponder?: CCResponder

    The next responder in the responder chain.

    subviews: CCView[] = []

    The list of subviews inside this view.

    superview?: CCView

    The view that contains this view, if it exists.

    userInteractionEnabled: boolean = true

    Whether user interaction is enabled for this view.

    window?: CCWindow

    The window this view is located inside.

    Accessors

    • get backgroundColor(): number | undefined

      The background color of the view.

      Returns number | undefined

    • set backgroundColor(value: number | undefined): void

      The background color of the view.

      Parameters

      • value: number | undefined

      Returns void

    • get contentView(): CCView

      Returns CCView

      Do not use this field on a table view.

    • get frame(): CCRect

      The position and size of the view.

      Returns CCRect

    • set frame(rect: CCRect): void

      Parameters

      Returns void

    • get rowColorA(): number

      The primary color for alternating rows.

      Returns number

    • set rowColorA(value: number): void

      Parameters

      • value: number

      Returns void

    • get rowColorB(): number

      The secondary color for alternating rows.

      Returns number

    • set rowColorB(value: number): void

      Parameters

      • value: number

      Returns void

    • get selectedRow(): number | number[] | null

      The currently selected row or rows.

      Returns number | number[] | null

    • set selectedRow(value: number | number[] | null): void

      Parameters

      • value: number | number[] | null

      Returns void

    • get selectedRowColor(): number

      The color for selected rows.

      Returns number

    • set selectedRowColor(value: number): void

      Parameters

      • value: number

      Returns void

    • get showHorizontalScrollBar(): boolean

      Whether to show the horizontal scrollbar.

      Returns boolean

    • set showHorizontalScrollBar(value: boolean): void

      Parameters

      • value: boolean

      Returns void

    • get showVerticalScrollBar(): boolean

      Whether to show the vertical scrollbar.

      Returns boolean

    • set showVerticalScrollBar(value: boolean): void

      Parameters

      • value: boolean

      Returns void

    • get sortColumn(): number | undefined

      Stores the 0-based index of the column determining sort order.

      Returns number | undefined

    • set sortColumn(value: number | undefined): void

      Parameters

      • value: number | undefined

      Returns void

    • get sortDirection(): boolean

      Stores the direction of sorting. Typically, false = A-Z, and true = Z-A.

      Returns boolean

    • set sortDirection(value: boolean): void

      Parameters

      • value: boolean

      Returns void

    Methods

    • This is used to place a blinking cursor on screen while not drawing. It's only called on the first responder of a window.

      Returns [CCPoint, number] | undefined

      The position and color of the cursor in window coordinates, or undefined to not place a cursor

    • Draws the view inside the specified rectangle. Override this function to provide custom view types.

      Parameters

      • rect: CCRect

        The rectangle to draw inside

      Returns void

    • Sends a list of key input events to the input manager, which will send back text input events through insertText(text: string).

      Parameters

      • events: CCEvent[]

        The input events to send

      Returns void

    • Returns whether the given row is selected.

      Parameters

      • row: number

        The row to check

      Returns boolean

      Whether the row is selected

    • Lays out the view hierarchy following constraints. This should only be called on a superview, which is done automatically.

      Returns void

    • Handles when a method action fails to find a responder.

      Parameters

      • method: string

        The method that was attempted

      Returns void

    • Tells the receiver that the frame or constraints of the sender changed. This triggers the receiver to update its constraints if any are related to the sender, and cascades the message up and down throughout the hierarchy. It will also trigger a cascade on itself if it needs to update constraints.

      Parameters

      • sender: CCView

        The view whose frame and/or constraints changed

      • previous: CCView

        The view that called this method, to prevent backtracking

      Returns void

    • Attempts to call the specified method on the object, passing the call on to the next responder if this object doesn't implement it.

      Parameters

      • method: string

        The name of the method to call

      • ...args: any[]

        Any parameters to pass to the method

      Returns boolean

      Whether a responder was able to respond to the method

    • Adds a number of constraints to views using code. This can simplify settings constraints by using familiar code syntax instead of lengthy constraint constructions and activations.

      The syntax is fairly simple:

      <ViewName>.<Attribute> = [<Multiplier> *] <ViewName>.<Attribute> [+|- <Constant>]
      <ViewName>.<Attribute> = <Constant>
      

      The code is processed using Lua as the parser, so it's not strictly required to be in exactly this format; but mind that operators other than add/sub/mul/div/unm aren't supported (and division is only valid if the divisor is a number), and no libraries are available in the environment.

      Parameters

      • code: string

        The constraint code to apply

      • views: { [name: string]: CCView }

        A key-value map of names of views in the code, to the views they represent

      Returns void