User Guide

ComboBox.restrict 195
You can use the backslash (\) to enter a hyphen (-), caret (^), or backslash (\) character, as
shown here:
\^
\-
\\
When you enter a backslash in the Actions panel within double quotation marks, it has a
special meaning for the Actions panel’s double-quote interpreter. It signifies that the character
following the backslash should be treated “as is.” For example, you could use the following
code to enter a single quotation mark:
var leftQuote = "\’";
The Actions panel’s restrict interpreter also uses the backslash as an escape character.
Therefore, you may think that the following should work:
myText.restrict = "0-9\-\^\\";
However, since this expression is surrounded by double quotation marks, the value 0-9-^\ is
sent to the restrict interpreter, and the restrict interpreter doesnt understand this value.
Because you must enter this expression within double quotation marks, you must not only
provide the expression for the restrict interpreter, but you must also escape the expression so
that it will be read correctly by the Actions panel’s built-in interpreter for double quotation
marks. To send the value
0-9\-\^\\ to the restrict interpreter, you must enter the
following code:
myCombo.restrict = "0-9\\-\\^\\\\";
The restrict property restricts only user interaction; a script may put any text into the text
field. This property does not synchronize with the Embed Font Outlines check boxes in the
Property inspector.
Example
With a ComboBox component instance my_cb, the following ActionScript restricts the entry
of characters to numbers 0-9, dashes, and dots:
// Add Items to List.
my_cb.addItem({data:1, label:"First Item"});
my_cb.addItem({data:2, label:"Second Item"});
// Enable editing of combo box.
my_cb.editable = true;
// Restrict the characters that can be entered into combo box.
my_cb.restrict = "0-9\\-\\.\\ ";