# class Application

#### package lime.app

#### extends Module

#### extended by Application

Available on all platforms

### Constructor

###

`new ()`

Creates a new Application instance

### Variables

###

`read onlyconfig:Config`

Configuration values for the application, such as window options or a package name

###

`frameRate:Float`

The current frame rate (measured in frames-per-second) of the application.

On some platforms, a frame rate of 60 or greater may imply vsync, which will perform more quickly on displays with a higher refresh rate

###

`read onlymodules:Array<IModule>`

A list of currently attached Module instances

###

`onUpdate:Event<Int ‑> Void> = new Event<Int>()`

Update events are dispatched each frame (usually just before rendering)

###

`read onlypreloader:Preloader`

The Preloader for the current Application

###

`read onlyrenderer:Renderer`

The Renderer associated with this Application, or the first Renderer if there are multiple Renderer instances

###

`read onlyrenderers:Array<Renderer>`

A list of Renderer instances associated with this Application

###

`read onlywindow:Window`

The Window associated with this Application, or the first Window if there are multiple Windows active

###

`read onlywindows:Array<Window>`

A list of active Window instances associated with this Application

### Methods

###

`addModule (module:IModule):Void`

Adds a new module to the Application

Parameters:

`module` | A module to add

###

`addRenderer (renderer:Renderer):Void`

Adds a new Renderer to the Application. By default, this is called automatically by create()

Parameters:

`renderer` | A Renderer object to add

###

`create (config:Config):Void`

Initializes the Application, using the settings defined in the config instance. By default, this is called automatically when building the project using Lime's command-line tools

Parameters:

`config` | A Config object

###

`createWindow (window:Window):Void`

Adds a new Window to the Application. By default, this is called automatically by create()

Parameters:

`window` | A Window object to add

###

`exec ():Int`

Execute the Application. On native platforms, this method blocks until the application is finished running. On other platforms, it will return immediately

Returns:

An exit code, 0 if there was no error

###

`removeModule (module:IModule):Void`

Removes a module from the Application

Parameters:

`module` | A module to remove

### Static variables

###

`staticread onlycurrent:Application`

The current Application instance that is executing

### Inherited Variables

#### Defined by Module

###

`onExit:Event<Int ‑> Void> = new Event<Int>()`

Exit events are dispatched when the application is exiting

### Inherited Methods

#### Defined by Module

###

`addWindow (window:Window):Void`

###

`onGamepadAxisMove (gamepad:Gamepad, axis:GamepadAxis, value:Float):Void`

Called when a gamepad axis move event is fired

Parameters:

`gamepad` | The current gamepad
`axis` | The axis that was moved
`value` | The axis value (between 0 and 1)

###

`onGamepadButtonDown (gamepad:Gamepad, button:GamepadButton):Void`

Called when a gamepad button down event is fired

Parameters:

`gamepad` | The current gamepad
`button` | The button that was pressed

###

`onGamepadButtonUp (gamepad:Gamepad, button:GamepadButton):Void`

Called when a gamepad button up event is fired

Parameters:

`gamepad` | The current gamepad
`button` | The button that was released

###

`onGamepadConnect (gamepad:Gamepad):Void`

Called when a gamepad is connected

Parameters:

`gamepad` | The gamepad that was connected

###

`onGamepadDisconnect (gamepad:Gamepad):Void`

Called when a gamepad is disconnected

Parameters:

`gamepad` | The gamepad that was disconnected

###

`onJoystickAxisMove (joystick:Joystick, axis:Int, value:Float):Void`

Called when a joystick axis move event is fired

Parameters:

`joystick` | The current joystick
`axis` | The axis that was moved
`value` | The axis value (between 0 and 1)

###

`onJoystickButtonDown (joystick:Joystick, button:Int):Void`

Called when a joystick button down event is fired

Parameters:

`joystick` | The current joystick
`button` | The button that was pressed

###

`onJoystickButtonUp (joystick:Joystick, button:Int):Void`

Called when a joystick button up event is fired

Parameters:

`joystick` | The current joystick
`button` | The button that was released

###

`onJoystickConnect (joystick:Joystick):Void`

Called when a joystick is connected

Parameters:

`joystick` | The joystick that was connected

###

`onJoystickDisconnect (joystick:Joystick):Void`

Called when a joystick is disconnected

Parameters:

`joystick` | The joystick that was disconnected

###

`onJoystickHatMove (joystick:Joystick, hat:Int, position:JoystickHatPosition):Void`

Called when a joystick hat move event is fired

Parameters:

`joystick` | The current joystick
`hat` | The hat that was moved
`position` | The current hat position

###

`onJoystickTrackballMove (joystick:Joystick, trackball:Int, x:Float, y:Float):Void`

Called when a joystick axis move event is fired

Parameters:

`joystick` | The current joystick
`trackball` | The trackball that was moved
`x` | The x movement of the trackball (between 0 and 1)
`y` | The y movement of the trackball (between 0 and 1)

###

`onKeyDown (window:Window, keyCode:KeyCode, modifier:KeyModifier):Void`

Called when a key down event is fired

Parameters:

`window` | The window dispatching the event
`keyCode` | The code of the key that was pressed
`modifier` | The modifier of the key that was pressed

###

`onKeyUp (window:Window, keyCode:KeyCode, modifier:KeyModifier):Void`

Called when a key up event is fired

Parameters:

`window` | The window dispatching the event
`keyCode` | The code of the key that was released
`modifier` | The modifier of the key that was released

###

`onMouseDown (window:Window, x:Float, y:Float, button:Int):Void`

Called when a mouse down event is fired

Parameters:

`window` | The window dispatching the event
`x` | The current x coordinate of the mouse
`y` | The current y coordinate of the mouse
`button` | The ID of the mouse button that was pressed

###

`onMouseMove (window:Window, x:Float, y:Float):Void`

Called when a mouse move event is fired

Parameters:

`window` | The window dispatching the event
`x` | The current x coordinate of the mouse
`y` | The current y coordinate of the mouse
`button` | The ID of the mouse button that was pressed

###

`onMouseMoveRelative (window:Window, x:Float, y:Float):Void`

Called when a mouse move relative event is fired

Parameters:

`window` | The window dispatching the event
`x` | The x movement of the mouse
`y` | The y movement of the mouse
`button` | The ID of the mouse button that was pressed

###

`onMouseUp (window:Window, x:Float, y:Float, button:Int):Void`

Called when a mouse up event is fired

Parameters:

`window` | The window dispatching the event
`x` | The current x coordinate of the mouse
`y` | The current y coordinate of the mouse
`button` | The ID of the button that was released

###

`onMouseWheel (window:Window, deltaX:Float, deltaY:Float):Void`

Called when a mouse wheel event is fired

Parameters:

`window` | The window dispatching the event
`deltaX` | The amount of horizontal scrolling (if applicable)
`deltaY` | The amount of vertical scrolling (if applicable)

###

`onPreloadComplete ():Void`

Called when a preload complete event is fired

###

`onPreloadProgress (loaded:Int, total:Int):Void`

Called when a preload progress event is fired

Parameters:

`loaded` | The number of items that are loaded
`total` | The total number of items will be loaded

###

`onRenderContextLost (renderer:Renderer):Void`

Called when a render context is lost

Parameters:

`renderer` | The renderer dispatching the event

###

`onRenderContextRestored (renderer:Renderer, context:RenderContext):Void`

Called when a render context is restored

Parameters:

`renderer` | The renderer dispatching the event
`context` | The current render context

###

`onTextEdit (window:Window, text:String, start:Int, length:Int):Void`

Called when a text edit event is fired

Parameters:

`window` | The window dispatching the event
`text` | The current replacement text
`start` | The starting index for the edit
`length` | The length of the edit

###

`onTextInput (window:Window, text:String):Void`

Called when a text input event is fired

Parameters:

`window` | The window dispatching the event
`text` | The current input text

###

`onTouchCancel (touch:Touch):Void`

Called when a touch cancel event is fired

Parameters:

`touch` | The current touch object

###

`onTouchEnd (touch:Touch):Void`

Called when a touch end event is fired

Parameters:

`touch` | The current touch object

###

`onTouchMove (touch:Touch):Void`

Called when a touch move event is fired

Parameters:

`touch` | The current touch object

###

`onTouchStart (touch:Touch):Void`

Called when a touch start event is fired

Parameters:

`touch` | The current touch object

###

`onWindowActivate (window:Window):Void`

Called when a window activate event is fired

Parameters:

`window` | The window dispatching the event

###

`onWindowCreate (window:Window):Void`

Called when a window create event is fired

Parameters:

`window` | The window dispatching the event

###

`onWindowDeactivate (window:Window):Void`

Called when a window deactivate event is fired

Parameters:

`window` | The window dispatching the event

###

`onWindowDropFile (window:Window, file:String):Void`

Called when a window drop file event is fired

Parameters:

`window` | The window dispatching the event

###

`onWindowEnter (window:Window):Void`

Called when a window enter event is fired

Parameters:

`window` | The window dispatching the event

###

`onWindowFocusIn (window:Window):Void`

Called when a window focus in event is fired

Parameters:

`window` | The window dispatching the event

###

`onWindowFocusOut (window:Window):Void`

Called when a window focus out event is fired

Parameters:

`window` | The window dispatching the event

###

`onWindowFullscreen (window:Window):Void`

Called when a window enters fullscreen

Parameters:

`window` | The window dispatching the event

###

`onWindowLeave (window:Window):Void`

Called when a window leave event is fired

Parameters:

`window` | The window dispatching the event

###

`onWindowMinimize (window:Window):Void`

Called when a window is minimized

Parameters:

`window` | The window dispatching the event

###

`onWindowMove (window:Window, x:Float, y:Float):Void`

Called when a window move event is fired

Parameters:

`window` | The window dispatching the event
`x` | The x position of the window in desktop coordinates
`y` | The y position of the window in desktop coordinates

###

`onWindowResize (window:Window, width:Int, height:Int):Void`

Called when a window resize event is fired

Parameters:

`window` | The window dispatching the event
`width` | The width of the window
`height` | The height of the window

###

`onWindowRestore (window:Window):Void`

Called when a window is restored from being minimized or fullscreen

Parameters:

`window` | The window dispatching the event

###

`registerModule (application:Application):Void`

###

`removeRenderer (renderer:Renderer):Void`

###

`render (renderer:Renderer):Void`

Called when a render event is fired

Parameters:

`renderer` | The renderer dispatching the event

###

`unregisterModule (application:Application):Void`

###

`update (deltaTime:Int):Void`

Called when an update event is fired

Parameters:

`deltaTime` | The amount of time in milliseconds that has elapsed since the last update