Skip to content
Anthony Ma edited this page May 26, 2015 · 6 revisions

A button is a clickable component that can have an action associated with it.

Fields

  • x default: 1 - x value of the component
  • y default: 1 - y value of the component
  • h default: 3 - height of the component
  • w default: 16 - width of the component
  • z default: 0 - z value of the component
  • parent - parent window object of the component
  • removed - whether the component has been queued for removal - should only be modified by the library itself
  • visible default: true - whether the component is visible
  • color default: colors.lightBlue - the background color
  • textColor default: colors.white - the color of the text
  • activeColor default: colors.blue - the color of the background color when the button is active
  • activeTextColor default: colors.white - the color of the text when the button is active
  • active default: false - whether the button is active - should only be modified by the library itself
  • text default: "txUI Button" - text displayed by the button
  • textAlign default: "center" - alignment of the text inside the button
  • vertCenter default: true - whether to vertically center the text

Functions

  • function action(self) - called by function click(self, x, y) when the button is clicked
  • function draw(self) - draws the button - should only be called by the library itself
  • function click(self, x, y) - called by the library on a click event to check if the button has been clicked
  • function update(self) - called every update cycle
  • function termX(self) - returns the x position on the terminal
  • function termY(self) - returns the y position on the terminal
  • function setPos(self, x, y) - sets the position of the component
  • function setSize(self, w, h) - sets the size of the component