Versions Compared
compared with
Key
- This line was added.
- This line was removed.
- Formatting was changed.
Description
The view element is used to specify details of the view. These include the view title, backing unit for the view and init function that should be called when the view is loaded. This Using the view element is required for all Helium application views as all other view components including data input widgets and data output widgets are placed within the view elementit.
Example
The following code snippet shows and example of how to use the view element.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
<?xml version="1.0" encoding="UTF-8"?> <ui xmlns="http://uiprogram.mezzanine.com/View" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://uiprogram.mezzanine.com/View ../View.xsd"> <view label="view_heading.shop_management" unit="ShopMgmt" init="init"> . . </view> </ui> |
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
unit ShopMgmt; . . void init() { . . } |
Code Block | ||
---|---|---|
| ||
view_heading.shop_management = Shop Management |
label="view_heading.shop_management"
This specifies the heading that will be displayed for the view. It is required and references a key in the lang file.
References from views to unit functions and variables can be done in two ways. Firstly, using the fully qualified name for the function or variables. This includes the unit name followed by a colon followed by the name of the function or variables. For example:unit="ShopMgmt"
MyUnit:myFunction
orMyUnit:myVariable
. Another way to reference a function and or variables in a view is to first specify the default unit for the view, as shown the code example above and them simply using the function and variables namesvariable name for reference.
It is often useful to have a unit function execute when a view loads in order to perform some initialization operations such as initializing unit variables used in the view. This is achieved by specifying the init function as in the example above:init="init"
init="init"
. Note that if a default unit is not specified, the init function has to be referenced using its fully qualified name:init="ShopMgmt:init"
.