Fieldtext behavior

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
mtecedor
Posts: 68
Joined: Fri Sep 04, 2009 6:40 pm

Fieldtext behavior

Post by mtecedor » Wed Jun 02, 2010 2:26 pm

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?

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10045
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Fieldtext behavior

Post by FourthWorld » Wed Jun 02, 2010 3:02 pm

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.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

mtecedor
Posts: 68
Joined: Fri Sep 04, 2009 6:40 pm

Re: Fieldtext behavior

Post by mtecedor » Thu Jun 03, 2010 2:53 pm

Thanks FourthWorld, that works, I didn't even know those functions existed

Marta

Post Reply