RE: Moving the Cursor

new topic     » goto parent     » topic index » view thread      » older message » newer message

Jon Snyder wrote:
> 
> 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...

<SNIP>

Sorry Jon, I have been a little busy the last couple of days and I
wasnt following along.  Just read all the posts, and thought I would
jump in.  It seems (to me) that you are looking for this:

==========
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

procedure change_edit()
    onChange[ NUMBER_EDIT] = -1
    setText( NUMBER_EDIT, addDashes( removeDashes( getText( NUMBER_EDIT) 
) ))
    onChange[ NUMBER_EDIT] = routine_id( "change_edit") 
end procedure
onChange[ NUMBER_EDIT] = routine_id( "change_edit") 

procedure KeyPress( atom keyCode, atom shift )
    atom RetVal
    if keyCode != 35 then
        RetVal = w32Func( xPostMessage, 
{getHandle(NUMBER_EDIT),WM_KEYDOWN,35,0} )
    end if
end procedure
onKeyDown[ NUMBER_EDIT] = routine_id( "KeyPress")
==========

Let me know if I am wrong...
Don Phillips

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu