editable fields

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

editable fields

Post by mtecedor » Tue Oct 13, 2009 6:29 pm

Hi All,

I am having problems with an editable field.

When users open the card the first time the field says: "Click here to add the topic"

I want this line to dissapear when users click on the field, so that they can add their own text.
If they click in a save button next time they go to that card they should find what they wrote, but if they didnt write anything, they should find again the line "Click here to add the topic".


Any idea how to get it to work?

I thought the way to think about it was programming revolution to recognize the string and then writing a condition, but I havent been able to write the code so that revolutionrecognize the string "Click here to add the topic".

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4171
Joined: Sun Jan 07, 2007 9:12 pm

Post by bn » Tue Oct 13, 2009 8:40 pm

Hi mtdecor,
how about putting this into your card script

Code: Select all

on opencard
   if  field "myField" is  "" then 
      put "Click here to add the topic" into field "myField"
   end if
end opencard
and this into the script of the field

Code: Select all

on mouseUp
   if the text of me is not "Click here to add the topic" then exit mouseUp
   set the locktext of me to false
   set the traversalon of me to true
   put empty into me
   select before text of me
end mouseUp

on closefield
   LockMe
end closefield

on focusOut
   LockMe
end focusOut

on returninfield
   LockMe
end returninfield

on enterinfield
   LockMe
end enterinfield

on LockMe
   set the locktext of me to true
   set the traversalon of me to false
end LockMe
just make shure field "myField" is locked and the traversalOn is false from the beginning.
into the save button you put

Code: Select all

on mouseUp
 send returninfield to field "myField"
   --
   -- continue with your saving
end mouseUp
see what happens and if it is what you want.
The way it is now the text of the field should be persistent.
Tell us if it is not what you want.
regards
Bernd[/code]

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

Post by mtecedor » Wed Oct 14, 2009 10:43 pm

Bern,

Thanks a lot, it works great.

Marta

Post Reply