Skip to content

BaseFrame ​

extends Container

BaseFrame: the root of a UI tree, bound to a terminal. Owns the render buffer, keyboard focus and mouse capture state.

Properties ​

PropertyTypeDefaultDescription
backgroundnumbercolors.blackBackground color (false = transparent)

Methods ​

BaseFrame:setup() ​

Initializes a new BaseFrame instance.

BaseFrame:isKeyDown(keyCode) ​

Returns whether a keyboard key is currently held down.

  • keyCode (number) ComputerCraft key code

  • returns down (boolean)

BaseFrame:setTerm(t) ​

Binds the root frame to a terminal-like object and resizes its buffer.

  • t (table) Terminal or monitor redirect

  • returns (self)

BaseFrame:draw() ​

Redraws the whole tree into the buffer if anything changed, then flushes the line diff to the terminal.

BaseFrame:setFocused(el) ​

Moves keyboard focus to an element, or clears it with nil.

  • el (Element, optional) New focused element

Applies a cursor request from a focused element (absolute coordinates). Forwards an absolute cursor request to the render buffer.

  • x (number) Absolute x coordinate

  • y (number) Absolute y coordinate

  • blink (boolean) Cursor blink state

  • color (number, optional) Cursor color

  • returns (self)

BaseFrame:getFocused() ​

Returns the element that currently owns keyboard focus.

  • returns element (Element|nil)

BaseFrame:handleEvent(event, a, b, c) ​

Entry point for raw CC events, called by the runtime. Dispatches one raw ComputerCraft event into this frame.

  • event (string) Event name
  • a (any) First event argument
  • b (any) Second event argument
  • c (any) Third event argument

BaseFrame:cleanup() ​

Restores the terminal (palette, colors, cursor).

Last updated:

Released under the MIT License.