Page 1 of 1

Fieldtext behavior

Posted: Wed Jun 02, 2010 2:26 pm
by mtecedor
Hi again,

I am getting a weird behaviour in one of my text fields and I don't know why. I have tried everything (or that's what I think) and I am going a bit insane.

So, I have this field, and I want that when the end user click on the field the first time, the original message (something like "type here") dissapears, so they do not have to delete it, and if they leave the field without typing anything, I want the original message to show back again. I also want to restrict the number of characters end users can type, and to prevent them from typing return.

So, this is what I have for the making the original message disappear. It does not work at all

Code: Select all

on mouseDown
     if  the text of me is "Conector" then
       put empty into me
    end if
end mouseDown
This is what I have for getting the original message back into the field if they havent typed anything. It does work sometimes

Code: Select all

on mouseLeave
   if the text of me is empty then
       put "Conector" into me
     
  end if
end mouseLeave
This is what I have for restricting the number of characters and preventing them to type return

Code: Select all

on rawKeyUp
  put the number of chars of me into tChars
  put 18 into tMaxChars 

  lock screen
  if (tChars > tMaxChars )  then
     answer "Has alcanzado el límite de espacio permitido. Revisa el texto y borra si quieres añadir algo más."
  end if

if thekey is 65293 then
exit rawKeyUp
end if
unlock screen
pass rawKeyUp
end rawKeyUp 


Any idea why this is not working?

Re: Fieldtext behavior

Posted: Wed Jun 02, 2010 3:02 pm
by FourthWorld
Rather than mouseDown and mouseLeave, use openField and exitField respectively.

The Dictionary entries for those tokens explain their differences and why the latter are the ones you want for an unlocked field.

Re: Fieldtext behavior

Posted: Thu Jun 03, 2010 2:53 pm
by mtecedor
Thanks FourthWorld, that works, I didn't even know those functions existed

Marta