Page tree
Skip to end of metadata
Go to start of metadata

This guide explains how to use enumerations with Smartface.

What is Enumeration ?

Enumeration defines a common type for a group of related values and enables you to work with those values in a type-safe way within your code.

Smartface Enumerations

Smartface has predefined enumerations to make your coding easy. You can find the complete list here.

Enumeration Rules

Returning Values

Smartface Enumerations are return number values. If you set an enum to any object or try to alert it, you will see that it is a number. For example, sample code which is written below returns 16 .

alert(SMF.UI.TextAlignment.CENTER);

Naming Convention

In Smartface, enumeration class name starts with captial letter and enumerations should be all capital letter.

For example;

	var lbl = new SMF.UI.Label({
		name: "lbl",
		text: "",
		left: "15%",
		top: "45%",
		width: "70%",
		height: "15%",
		multipleLine: true
	});
	lbl.textAlignment = SMF.UI.TextAlignment.CENTER; // TextAlignment Enumeration
	lbl.borderColor = SMF.UI.Color.RED; // Color Enumeration

Enumeration Accepting Values

Enumeration accepting values also can be set to string. This string is same as enum value name and It's case insensitive. As an example;

	var lbl = new SMF.UI.Label({
		name: "lbl",
		text: "",
		left: "15%",
		top: "45%",
		width: "70%",
		height: "15%",
		multipleLine: true
	});
	lbl.textAlignment = SMF.UI.TextAlignment.CENTER;
	lbl.borderColor = SMF.UI.Color.RED; //or
	lbl.borderColor = 'RED'; //or
	lbl.borderColor = 'red';