Skip to content
AR2000 edited this page Jul 20, 2023 · 2 revisions

Widget

Abstract class. The base for all widgets.

Widget(parent:Frame, x:number,y:number):Widget

Parameters :

  • parent:Frame - The Widget's parent
  • x:number - x position relative to the parent
  • y:number - y position relative to the parent

Return :

  • Widget - a Widget instance

widget:getParent()

Return :

  • Frame - The frame the widget is in

widget:position([x:number,y:number]):number,number

Getter and setter for the widget's position. If x and y are set, the position will be updated. Return the old or current position.

Parameters :

  • x:number - x position relative to the parent
  • y:number - y position relative to the parent

Return :

  • x:number - the old x position relative to the parent
  • y:number - the old y position relative to the parent

widget:x([x:number]):number

Getter and setter for the widget's x position. If x and is set, the position will be updated. Return the old or current position.

Parameters :

  • x:number - x position relative to the parent

Return :

  • x:number - the old x position relative to the parent

widget:y([y:number]):number

Getter and setter for the widget's y position. If y and is set, the position will be updated. Return the old or current position.

Parameters :

  • y:number - y position relative to the parent

Return :

  • y:number - the old y position relative to the parent

widget:z([z:number]):number

Getter and setter for the widget's z position. If z and is set, the position will be updated. Return the old or current position.

Parameters :

  • z:number - z position relative to the parent

Return :

  • z:number - the old z position relative to the parent

widget:absX():number

Get the widget absolute x position on screen.

Return :

  • x:number - absolute x position on screen

widget:absY():number

Get the widget absolute y position on screen.

Return :

  • y:number - absolute y position on screen

widget:absPosition():number,number

Get the widget absolute position on screen.

Return :

  • x:number - absolute x position on screen
  • y:number - absolute y position on screen

widget:width([width:number]):number

Getter and setter for the widget's width. If width and is set, the width will be updated. Return the old or current width.

Parameters :

  • width:number - widget's width Return
  • width:number - the widget's width

widget:height([height:number]):number

Getter and setter for the widget's width. If width and is set, the height will be updated. Return the old or current height.

Parameters :

  • height:number - widget's height Return
  • height:number - the widget's height

widget:size([width:number, height:number]):number,number

Getter and setter for the widget's size. If width and height are set, the size will be updated. Return the old or current size.

Parameters :

  • width:number - width relative to the parent
  • height:number - height relative to the parent

Return :

  • width:number - the old width relative to the parent
  • height:number - the old height relative to the parent

widget:visible([value:boolean]):boolean

Getter and setter for the widget's visibility. If value is set, the visibility will be updated. Return the old or current visibility.

Parameters :

  • value:boolean - new visible state Returns :
  • visible:boolean - the widget's visibility state

widget:enabled([value:boolean]):boolean

Getter and setter for the widget's enabled state. If value is set, the enabled state will be updated. Return the old or current enabled state.

Parameters :

  • value:boolean - new visible enabled state Returns :
  • visible:boolean - the widget's enabled state

widget:callback([callback:function, ...:any])

Getter and setter for the function called when the widget is interacted with with the mouse. Return the old or current callback function when no arguments are given

Parameters :

  • callback:function - func(self:Widget,...:any,eventsValues...:any)
  • ...:any - additional parameters to call the function with

Return :

  • callback:function
  • ...:table - the additional arguments passed to the function in a table.

widget:checkCollision(x:number, y:number):boolean

Check if the given position is on the widget. The check is done against the absolute position. Parameters

  • x:number - absolute x position on screen
  • y:number - absolute y position on screen

Return :

  • collide : boolean

widget:draw()

Draw the widget on screen