Difference between revisions of "LGUI2:Item View Generators"

From Lavish Software Wiki
Jump to navigation Jump to search
Line 37: Line 37:
 
== Examples ==
 
== Examples ==
  
 +
{{LGUI2:Topic}}
 
[[Category:LavishGUI 2]]
 
[[Category:LavishGUI 2]]
 
[[Category:LavishGUI 2 Items]]
 
[[Category:LavishGUI 2 Items]]

Revision as of 04:31, 15 July 2018

An Item View Generator (also often referred to as a "factory") in LavishGUI 2 is responsible for creating an itemview when given an Item. This allows different types of Items to be represented in different ways.

Defining an Item View Generator

Item View Generators are created much like Event Handlers, supporting "code" and "method" types.

As a JSON Array

When defining an Item View Generator with a JSON array, each item in the array is expected to be a string, and we will refer to them as parameters.

The first parameter is to be the type of Item View Generator, one of "code" or "method". Following the type parameter will be any type-specific parameters.

Item View Generator types defined by JSON Arrays
  • code: Code requires only one additional parameter, being LavishScript code to execute. Example: ["code","echo Hi mom!"]
  • method: Method requires two parameters in this order. First, the LavishScript object (globally accessible) with the method to execute. Second, the name of the method to execute. Example: ["method","MyUIController","GenerateItemView"]. This case is also equivalent to ["code","MyUIController:GenerateItemView"].

As a JSON Object

Item View Generator properties
type One of "method" or "code", with additional properties below depending on the type
"method" type
object The LavishScript object (globally accessible) with the method to execute
method The method on the object to execute
"code" type
code LavishScript code to execute


Examples

LavishGUI 2 Topics