Moving the Cursor
- Posted by Jon Snyder <jongsnyder at hotmail.com> Aug 09, 2002
- 539 views
I'm trying to create an input field for a phone number that will automatically add the dashes while the number is being input. The problem is, is that after calling setText() the cursor is put at the begining of the edit box so the number is entered backwards. Is there a way to move the cursor to the end of the edit box? Here is the code i have so far... function removeDashes( sequence line) sequence new_line new_line = {} for i = 1 to length( line) do if line[i] != '-' then new_line &= line[i] end if end for return new_line end function function addDashes( sequence text) integer length_text length_text = length( text) if length_text > 3 then text = text[1..3] & '-' & text[4..length_text] end if if length_text > 8 then text = text[1..7] & '-' & text[8..length_text+1] end if return text end function boolean changing changing = FALSE procedure change_edit() if not changing then changing = TRUE setText( NUMBER_EDIT, addDashes( removeDashes( getText( NUMBER_EDIT) ) )) changing = FALSE end if end procedure onChange[ NUMBER_EDIT] = routine_id( "change_edit")