Altova MobileTogether Designer

Measure Controls

Home Prev Top Next

The Measure Controls action (screenshot below) returns the minimum width in pixels of the specified control kind (button or label, for example) when the string specified in the first setting is the display-text of the control. The action can be used to find control widths of a set of strings and to then use this information in your design. For example, you could find the width of all buttons in a column and then set the width of this column according to the largest button-width.

MTActionMeasureControls

Text strings of controls

Since the control width is dependent on the size of its text, you must provide in the first setting the string that you want to place on the control. If you want to find out the widths of multiple controls, each having a different text, then supply all these texts as the string items of a sequence. The return value will be a sequence containing the widths of each string. This sequence will be stored in the MT_MeasureControls variable. For example, in the screenshot above, we have supplied a sequence of two strings: ("Altova Product", "Go to Product Description"). These strings do not actually have to be present on controls in the design. The return value will contain two number values, which are respectively the widths of the two strings. You could add any string to the sequence to find out the control width for that string.

 

Text parameters

The second setting must be an XPath map expression that specifies the parameters for which the width calculation is made. The parameters include such information as whether the control being measured is a label or a button, or whether the text size is small or medium, or whether the text is bold or not. The keys of the map and their allowed values are listed below. The only mandatory key is "Control Kind". If a key is not specified, then its default value is used. In the screenshot above, for example, the width is being measured for buttons on which the text appears with the default values of the respective parameters. The XPath expression is: map{"Control Kind":"Button"}.

 

Key

Value

Default

Control Kind

"Label"|"Button"

Mandatory value

Text Size

"small"|"medium"|"large"

"medium"

Unit

"px"|"dp"|"sp"|"". See Sizes: Pixels, DPI, DP, SP.

"px"

Bold Text

"true"|"false"

"false"

Italic Text

"true"|"false"

"false"

Underline Text

"true"|"false"

"false"

Button Image

Any of the Button Image options (for example, + or - or > or Share

None

Button Background

"transparent"|"not_transparent"

"not_transparent"

 

 

The Parameters argument is a key-value map that defines the properties of the control. The available keys and their values are listed below. The integer that is returned is the minimum width, in pixels, of the control when the submitted Text string (first setting) is displayed with the properties specified in the Parameters argument. This value can then be used to calculate and specify other properties related to the control, such as the widths of table columns in which the control appears.

 

The return value and the "MT_MeasureControls" variable

The action returns a sequence of numbers, which is automatically stored in the MT_MeasureControls variable. You can use MT_MeasureControls in the XPath expressions of actions. Since the items in the returned sequence are numbers, you can use the max() function to find out the largest control width (for example: max(MT_MeasureControls)). Another useful function is the serialize() function, which can be used to display the complete sequence.

 

Points to note

Note the following points:

 

For each action, you can find out the widths of one control kind only. To find out the widths of another control kind, call the action a second time with a new Control Kind parameter value.

This action provides the same functionality as the mt-control-width() function. A key difference is that the function cannot be used for web-client rendering, whereas the action can be used for web clients.

 

MobileTogether extension functions

MobileTogether provides a range of XPath extension functions that have been specifically created for use in MobileTogether designs. Some functions can be particularly useful with specific actions. For example, mt-available-languages() returns the languages in which the solution is available and could, for example, be used with the Message Box action. If a function is especially relevant to this action, it is listed below. For a full list of extension functions and their descriptions, see the topic MobileTogether Extension Functions.

 

© 2017-2023 Altova GmbH