Phone API Reference - UI Classes (Widgets) - Text

Desk Phone API features described in this section are deprecated and supported only on the following models: D40, d45, d50, d60, d62, d65, d70

Widget used for drawing text on the screen.

Class Constructor

new Text()

Creates a new Text Object.

 var textObj = new Text(x, y, width, height[, label]); //new Text Widget

 

Initialization Parameters

Name

Required

Type

Default

Description

Name

Required

Type

Default

Description

x

Yes

integer

 

x coordinate value for top left corner.

y

Yes

integer

 

y coordinate value for top left corner.

width

Yes

integer

 

Width in pixels.

height

Yes

integer

 

Height in pixels.

label

No

string

 

Text to display

 

Class Constants

Title 

Description 

Title 

Description 

Text.LINE_HEIGHT

 

 

 

D6X Only

Text.LINE_HEIGHT_2

Text.ROW_HEIGHT

Text.TITLE_HEIGHT

Recommended number of pixels to use for the height of a line of text.  You can put another line at y+Text.LINE_HEIGHT, and it will render correctly. This property is dependent on the model of phone the app is running on. For the D6X models three more height definitions are specified. They are Text.LINE_HEIGHT_2, Text.ROW_HEIGHT, and Text.TITLE_HEIGHT.

  • LINE_HEIGHT = 15 for D40/D50 (~6 lines per screen minus title and soft keys, also height of titles)

  • LINE_HEIGHT = 17 for D70 (~7 lines per screen minus title and soft keys, also height of titles)

  • LINE_HEIGHT = 25 for D6X (~8 lines per screen, minus title and soft keys)

  • LINE_HEIGHT_2 = 28 (~7 lines per screen, minus title and soft keys)

  • ROW_HEIGHT = 32 (~6 lines per screen, minus title and soft keys, used by most D6X screens, leaves good spacing, and room for border lines)

  • TITLE_HEIGHT = 40 (title bar heights of all D6X screens)

 

Basic Example:

var h = Text.LINE_HEIGHT; //retrieve our models line height for use below new Text(0,0, 100, h);

This Class inherits methods and properties from the Widget Base Class. See  Widget Base Class  for more information about setting your Object's x, y, w, and h properties or adding children to it.

 

Methods

Name 

Description 

Name 

Description 

align

Controls the placement of the text display.

fitLabel

Resizes the box around the widget to fit it to the contents. A padding argument is optional, to add additional pixels on each side of the text.

 

Properties

Name 

Description 

Name 

Description 

label

The string to display. Change the string of a Text object without having to re instantiate one.

Basic Example:

textObj.label = "New Value for Display"; 

labelColor

Color of the text. Can be white or black for D40, D50, and D70, or any of the colors specified in the Base Class color properties for the D6X models.

Basic Example:

labelSize

The font size of the label. The default value differs based on phone model, so it is best to make changes relative to the current size instead of specifying a specific size. For example, if you have some bit of text you want a bit larger in your app then create a Text object and multiple it's current label size by 1.2.

Basic Example:

Return to Documentation Home I Return to Sangoma Support