PackageTop Level
Classpublic class Application

This class represents an application. You do not need to directly create an instance of it. Instead, directly use the methods and properties of the appetizer global object.

This class dispatches the following events:

NameTypeDispatched...
trayIconMenuOpeningMenuOpeningwhen the tray icon menu is about to be displayed
dockItemMenuOpeningDockItemMenuOpeningwhen a dock item menu is about to be displayed
dockItemClickDockItemClickwhen a dock item is clicked
readyReadywhen the application is fully ready
closeClosewhen the application is about to be closed

See also

Global.appetizer


Public Methods
 MethodDefined by
  
addEventListener(eventName:String, callback:String):void
This method lets you register event listener functions with the specified control or object.
Application
  
close():void
Closes the application.
Application
  
disable():void
Disables the application.
Application
  
Triggers multi-launch functionality.
Application
  
enable(enable:Boolean = true):void
Enables the application.
Application
  
Gets the application data directory
Application
  
getDirectory():String
Gets the application directory
Application
  
Gets the dock item with the given id or nil if it does not exist or has been deleted.
Application
  
Returns the root of all the dock items.
Application
  
getDrive():String
Returns the drive on which the application is running.
Application
  
getFilePath():String
Gets the application file path
Application
  
getOrientation():String
Gets the application orientation.
Application
  
getSkinNames():Array
Returns the list of skins currently installed.
Application
  
hide():void
Hides the application.
Application
  
Installs Appetizer's autorun.inf file at the root of the current drive.
Application
  
isVisible():Boolean
Tells whether the application is visible or not.
Application
  
setOrientation(orientation:String):void
Sets the application orientation.
Application
  
setSkin(skinName:String):void
Switches the skin to the given skin name.
Application
  
show():void
Shows the application.
Application
  
showHelpFile(sectionName:String = ""):void
Opens the help file.
Application
Method detail
addEventListener()method
public function addEventListener(eventName:String, callback:String):void

This method lets you register event listener functions with the specified control or object. The event listener functions always receive an event object as a parameter. This event has, among other, a sender property which is a reference to the object that has dispatched the event. This object may also have additional properties which depend on the the event.

Parameters
eventName:String — The event you wish to listen to.
 
callback:String — The Lua function to call when the event is triggered.

Example
The following code registers a listener for the "trayIconMenuOpening" event, which is triggered when the user right-click on the tray icon. A menu item is then added to the menu.
  
 function appetizer_trayIconMenuOpening(event)  
     trace("Sender: "..event.sender) -- the application is the sender  
  
     -- The tray icon menu is about to be shown, but before it is  
     -- we add a menu item to it.  
     menu = event.menu -- get the tray icon menu  
  
     menu:appendSeparator()  
  
     menuItem = MenuItem:new("Tray Icon Test")  
  
     menu:append(menuItem)  
 end  
  
 appetizer:addEventListener("trayIconMenuOpening", "appetizer_trayIconMenuOpening")  
  
 trace("Listening to the "trayIconMenuOpening" event...")  
 

close()method 
public function close():void

Closes the application.

disable()method 
public function disable():void

Disables the application.

See also

doMultiLaunch()method 
public function doMultiLaunch():void

Triggers multi-launch functionality. See Appetizer's help file for some information about this feature.

enable()method 
public function enable(enable:Boolean = true):void

Enables the application.

Parameters
enable:Boolean (default = true) — Sets this to false to disable the application instead

See also

getDataDirectory()method 
public function getDataDirectory():String

Gets the application data directory

Returns
String — The application data directory
getDirectory()method 
public function getDirectory():String

Gets the application directory

Returns
String — The application directory
getDockItemById()method 
public function getDockItemById():DockItem

Gets the dock item with the given id or nil if it does not exist or has been deleted. Note that this function will also look for the dock item in all the groups and subgroups starting from the root.

Returns
DockItem — The dock item or nil if does not exists.
getDockItemsRoot()method 
public function getDockItemsRoot():DockItem

Returns the root of all the dock items. Dock items are organized in a tree-like structure with groups being the branches and the shortcut being the leafs. This function allows getting the root of this structure. You can then call childrenCount(), getChildAt(), etc. to access the children.

Returns
DockItem — The root of all the dock items.

Example
The following code gets the dock items' root and prints the name of all its children.
  
 root = appetizer:getDockItemsRoot()  
 childrenCount = root:childrenCount()  
  
 for i = 0, (childrenCount - 1) do  
     subDockItem = root:getChildAt(i)  
     trace(subDockItem:getName())  
 end  
 

getDrive()method 
public function getDrive():String

Returns the drive on which the application is running.

Returns
String — Drive name.
getFilePath()method 
public function getFilePath():String

Gets the application file path

Returns
String — The application file path
getOrientation()method 
public function getOrientation():String

Gets the application orientation.

Returns
String — Can be "horizontal" or "vertical".

See also

getSkinNames()method 
public function getSkinNames():Array

Returns the list of skins currently installed.

Returns
Array — The list of string names.
hide()method 
public function hide():void

Hides the application.

installAutoRunFile()method 
public function installAutoRunFile():void

Installs Appetizer's autorun.inf file at the root of the current drive.

isVisible()method 
public function isVisible():Boolean

Tells whether the application is visible or not.

Returns
Booleantrue if the application is visible.

Example
The following code toggles the application visibility.
  
 function hideShowToggle()  
     if appetizer:isVisible() then  
         appetizer:hide()  
     else  
         appetizer:show()  
     end  
 end  
  
 hideShowToggle()  
 

setOrientation()method 
public function setOrientation(orientation:String):void

Sets the application orientation.

Parameters
orientation:String — Can be "horizontal" or "vertical".

Example
The following code rotates the application.
  
 function rotateApplication()  
     if appetizer:getOrientation() == "horizontal" then  
         appetizer:setOrientation("vertical")  
     else  
         appetizer:setOrientation("horizontal")  
     end  
 end  
  
 rotateApplication()  
 

setSkin()method 
public function setSkin(skinName:String):void

Switches the skin to the given skin name. Use getSkinNames to get the list of possible skins.

Parameters
skinName:String — The skin name.

See also

show()method 
public function show():void

Shows the application.

showHelpFile()method 
public function showHelpFile(sectionName:String = ""):void

Opens the help file.

Parameters
sectionName:String (default = "") — The section to open the help file at.