viewer.setCursorAdded by IBM on October 10, 2012 | Version 1 (Original)
|Places the cursor at a specific location in a field or highlights a specific section of text within a field. Use this function when you want the user to start typing after some information that is already in a field, or when you want the user to replace a specific section of text.
Table 1. viewer.setCursor parameters
|startValue||Integer||The start position of the cursor within a field.|
|endValue||Integer||Optional. The end position of the highlighted text within a field.|
Returns 1 if function is successful or 0 if errors occur.
- If both parameters have the same value, the cursor is placed at the location indicated.
- If the endValue is less than startValue, the second parameter is ignored and the cursor is placed at the location indicated by the first parameter.
- If the endValue is greater than the length of the field, all of the text and white space (such as spaces) in the field, from the location indicated by the first parameter to the end of the field, is highlighted.
Example In this example, when the user tabs into the field, the word "shall" is highlighted. Note that setCursor must be used in conjunction with the toggle function .
<field sid = "FIELD1">
<label>Set Cursor Field</label>
<custom:set_cursor xfdl:compute="toggle(focused, 'off', 'on')
== '1' ? viewer.setCursor('6', '10') : ''"></custom:set_cursor>
<value>What shall we do with the drunken sailor?</value>