RE: Moving the Cursor

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

rudy toews wrote:
> 
> 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...
> > 
> > 
> > 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")
> > 
> > 
> hi Jon,
> still learning the windows programming myself.
> sorry i have no code to show you. but how about..
> an edit box for each part of the phone number, placed beside one another 
> 
> making it look like one box.
> as each part of the phone number is keyed then the appropriate box is 
> used by the code. an edit box could be the hyphen all by itself in 
> between the other parts of the phone number. would work if area code is 
> entered. if 3 numbers are keyed then they are assigned to the first box 
> then the remainder is assigned to the box after the hyphen.
> 
> later
> rudy toews
> 
> lotterywars
> 

I thought about doing that, but i don't like that.  I have a box that is 
the default area code and then a box that takes either a 7 digit number 
or a 10 digit number.  Even with your solution i would need to know how 
to move the cursor to the end of the edit box because if the backspace 
key was hitat the begining of the second box, the cursor should move to 
the end of the first box.

--jon snyder

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

Search



Quick Links

User menu

Not signed in.

Misc Menu