File component/Context.lua

A Context contains a contentView, which holds an array of subviews to be displayed on the screen. These views also receive mouse and key events directed to them from the Context.

Functions

Context:addSubview (...) Adds subviews to the context
Context:draw (...) Call this when your app is drawing the frame
Context:getContentView () Gets the contentView
Context:getFirstResponder () Gets the firstResponder
Context:init () Initializes the context object
Context:keypressed (key, unicode) Call this when your app detects a key press.
Context:keyreleased (key, unicode) Call this when your app detects a key release.
Context:load (lib) Loads the Context class, automatically called when it's required by LoveUI
Context:mousepressed (x, y, button) Call this when your app detects a mouse press.
Context:mousereleased (x, y, button) Call this when your app detects a mouse release.
Context:setContentView (view) Sets the contentView
Context:setFirstResponder (aResponder) Sets the firstResponder
Context:triggerKeyEvent (key, unicode) Sets up a key event.
Context:triggerMouseEvent (x, y, button) Sets up a mouse event.
Context:update (...) Call this when your app is updating the frame


Functions

Context:addSubview (...)
Adds subviews to the context

Parameters

  • ...: a list of subviews separated by commas
Context:draw (...)
Call this when your app is drawing the frame

Parameters

  • ...: passed to views
Context:getContentView ()
Gets the contentView

Return value:

object
Context:getFirstResponder ()
Gets the firstResponder

Return value:

object
Context:init ()
Initializes the context object

Return value:

object
Context:keypressed (key, unicode)
Call this when your app detects a key press. key is the keyCode of the key released.

Parameters

  • key: number
  • unicode: [optional] number
Context:keyreleased (key, unicode)
Call this when your app detects a key release. key is the keyCode of the key released.

Parameters

  • key: number
  • unicode: [optional] number
Context:load (lib)
Loads the Context class, automatically called when it's required by LoveUI

Parameters

  • lib: table

Return value:

class
Context:mousepressed (x, y, button)
Call this when your app detects a mouse press. 1 is left, 2 is right

Parameters

  • x: number
  • y: number
  • button: number
Context:mousereleased (x, y, button)
Call this when your app detects a mouse release. 1 is left, 2 is right

Parameters

  • x: number
  • y: number
  • button: number
Context:setContentView (view)
Sets the contentView

Parameters

  • view: object
Context:setFirstResponder (aResponder)
Sets the firstResponder

Parameters

  • aResponder: object
Context:triggerKeyEvent (key, unicode)
Sets up a key event. Used by keypressed and keyreleased

Parameters

  • key: number
  • unicode: number
Context:triggerMouseEvent (x, y, button)
Sets up a mouse event. Used by mousepressed and mousereleased

Parameters

  • x: number
  • y: number
  • button: number
Context:update (...)
Call this when your app is updating the frame

Parameters

  • ...: passed to views

Valid XHTML 1.0!