PackageTop Level
Classpublic class Preferences

Preferences provide a persitent data storage for plugins. The preferences are saved when Appetizer is closed and restored when it restarts. Preferences must be defined at the begining of a Lua script using registerPreference(). And it is then possible to get or set their values using getValue() and setValue(). If a plugin has preferences the "Options" button will be enabled in the Configuration dialog, which will allow the user to change the preferences. It is also possible to programmatically show this dialog box using dialogs:showPreferences()



Public Methods
 MethodDefined by
  
getValue(name:String):Object
Gets the value of the given preference.
Preferences
  
registerPreference(preference:Array):void
Registers a preference.
Preferences
  
registerPreferenceGroup(name:String, title:String):void
Preferences can be grouped into tabs.
Preferences
  
setValue(name:String, value:Object):void
Sets the value of the given preference.
Preferences
Method detail
getValue()method
public function getValue(name:String):Object

Gets the value of the given preference.

Parameters
name:String — Name of the preference

Returns
Object — Value of the preference
registerPreference()method 
public function registerPreference(preference:Array):void

Registers a preference. Preferences must be registered before they appear in the Preference dialog, and before their values can be accessed. A preference is an associative array, which can contain the following values:

NameTypeRequired?Description
typeStringyesCan be any of these types: Text, TextArea, Popup, CheckBox, File, Spinner, Hidden
nameStringyesName of the preference. Must be unique.
defaultValueAnynoDefault value.
titleStringnoTitle of the preference, as displayed in the Preference dialog.
descriptionStringnoDescription of the preference. It is displayed below the control in the Preference dialog
groupStringnoOptional preference group
minValueNumbernoUsed by the Spinner control to specify the value range
maxValueNumbernoUsed by the Spinner control to specify the value range
secureBooleannoSets it to true to make a text field secure (eg. for password input)
optionsArraynoAssociative array of key / value pairs to specify the available options for the Popup control.

Parameters
preference:Array — Preference to register

Example
This script registers two preferences.
  
 -- The example below register two preferences. One text area and one checkbox  
  
 preferences:registerPreference({  
   type = "TextArea",  
   name = "textAreaExample",  
   defaultValue = "Type-in some text in this boxx",  
   title = "Text area example:"  
 })  
  
 preferences:registerPreference({  
   type = "CheckBox",  
   name = "checkboxExample",  
   defaultValue = false,  
   title = "Are you sure?"  
 })  
 

registerPreferenceGroup()method 
public function registerPreferenceGroup(name:String, title:String):void

Preferences can be grouped into tabs. To create a new group, use this function. you can then assign a preference to it by using the group property.

Parameters
name:String — Name of the group
 
title:String — Title of the group

Example
This script registers a preference group.
  
 preferences:registerPreferenceGroup("advancedOptions", "Advanced")  
 

setValue()method 
public function setValue(name:String, value:Object):void

Sets the value of the given preference.

Parameters
name:String — Name of the preference
 
value:Object — New value of the preference