Skip to content
Benedict Allen edited this page Nov 15, 2015 · 5 revisions

Sheet Class

The Sheet class is the base class for all UI components. Anything the user can interact with is either a Sheet or extends it.

Constructor

Sheet( number x, number y, number width, number height )

Implements

Callbacks

onParentResized()

Sheet:onParentResized()

Called when the Sheet's parent resizes.

onMouseEvent()

Sheet:onMouseEvent( MouseEvent event )

Called when the Sheet gets a mouse event.

onKeyboardEvent()

Sheet:onKeyboardEvent( KeyboardEvent event )

Called when the Sheet gets a keyboard event (and has the handlesKeyboard property).

onTextEvent()

Sheet:onTextEvent( TextEvent event )

Called when the Sheet gets a mouse event (and has the handlesText property).

onUpdate()

Sheet:onUpdate( number dt )

Called when the Sheet updates.

onPreDraw()

Sheet:onPreDraw()

Called before the Sheet draws its children.

onPostDraw()

Sheet:onPostDraw()

Called after the Sheet draws its children.

Variables

x

Sheet.x - number

The X position of the Sheet, based at 0.

y

Sheet.y - number

The Y position of the Sheet, based at 0.

z

Sheet.z - number

The Z position of the Sheet, based at 0.

id

Sheet.id - string

The ID of the Sheet.

style

Sheet.style - Style

The unique Style of the Sheet.

parent

Sheet.parent - nil, Sheet, or Screen

The Sheet's parent. See Object Structure Tutorial.

canvas

Sheet.canvas - DrawingCanvas

The canvas holding the Sheet's graphical content.

changed

Sheet.changed - boolean

Whether the Sheet has changes to draw.

handlesKeyboard

Sheet.handlesKeyboard - boolean

Whether the Sheet should get keyboard events.

handlesText

Sheet.handlesText - boolean

Whether the Sheet should get text events.

cursor_active

Sheet.cursor_active - boolean

Whether the Sheet has its cursor blink enabled.

cursor_colour

Sheet.cursor_colour - number

The colour of the cursor, if present.

cursor_x

Sheet.cursor_x - number

The X position of the cursor, if present.

cursor_y

Sheet.cursor_y - number

The Y position of the cursor, if present.

Methods

setX()

This method is chainable.

Sheet:setX( number x )

Sets the X position of the Sheet, and tells its parent to redraw.

setY()

This method is chainable.

Sheet:setY( number y )

Sets the Y position of the Sheet, and tells its parent to redraw.

setZ()

This method is chainable.

Sheet:setZ( number z )

Sets the Z position of the Sheet, and tells its parent to redraw.

setID()

This method is chainable.

Sheet:setID( string id )

Sets the ID of the Sheet.

setStyle()

This method is chainable.

Sheet:setStyle( Style style, boolean children = false )

Sets the style of the Sheet, and of children sheets if children is true.

setParent()

This method is chainable.

Sheet:setParent( Sheet/Screen/nil parent )

Sets the parent of the Sheet.

remove()

Sheet:remove()

Removes the Sheet from its parent, returning itself if had a parent to be removed from.

isVisible()

boolean visible = Sheet:isVisible()

Returns whether the Sheet is visible inside its parent's canvas (doesn't take overlapping elements into account).

bringToFront()

This method is chainable.

Sheet:bringToFront()

Brings the Sheet in front of all other sheets with the same Z value and the same parent.

setChanged()

This method is chainable.

Sheet:setChanged( boolean state = true )

Tells the Sheet (and its parent) that it needs to redraw.

setCursorBlink()

This method is chainable.

Sheet:setCursorBlink( number x, number y, number colour = WHITE )

Sets the Sheet's internal cursor blink, causing a redraw.

resetCursorBlink()

This method is chainable.

Sheet:resetCursorBlink()

Disables the Sheet's internal cursor blink, causing a redraw.

update()

Sheet:update( number dt )

Updates the Sheet and its animations.

draw()

Sheet:draw()

Redraws the Sheet if it has changed.

handle()

Sheet:handle( Event event )

Passes an event to the Sheet.

Clone this wiki locally