Clearing text in text field

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
tasdvl9
Posts: 94
Joined: Fri Dec 06, 2013 3:55 am

Clearing text in text field

Post by tasdvl9 » Sun Feb 16, 2014 3:25 am

Hello,

How do I clear text in my text field when I start typing into it?

For instance, I have a default text string in my text field but as soon as I type a letter I want to clear the field.

Thanks!

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10333
Joined: Wed May 06, 2009 2:28 pm

Re: Clearing text in text field

Post by dunbarx » Sun Feb 16, 2014 4:20 am

Hi.

Not sure I get this. You already have text in a field, and you want to insert the cursor into that field so that the very next character you type clears the original text so the new text can be entered from the top?

You know that when you click on an editable field, the insertion point is automatically set at the end of the existing text, right? So if you have an empty field, the cursor seems to be at the beginning, and if you already have text, the cursor is at the end. This is actually identical behavior, if you think about it.

Please write back if any of what I just said makes sense to you, or if any of it is pertinent to what you are trying to do. There are about a million ways to do this sort of thing, but I suspect that what you actually asked for is not the best way to go about it, (that the first char typed, after setting the insertion point in existing text, makes that text go away, and the new text starts at the beginning).

Craig Newman

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10333
Joined: Wed May 06, 2009 2:28 pm

Re: Clearing text in text field

Post by dunbarx » Sun Feb 16, 2014 4:38 am

EDIT:

Try this in the field script, and see if it is sort of what you had in mind:

Code: Select all

on openField
   put empty into me
   select text of me
end openField

tasdvl9
Posts: 94
Joined: Fri Dec 06, 2013 3:55 am

Re: Clearing text in text field

Post by tasdvl9 » Sun Feb 16, 2014 4:49 am

Thanks dunbarx!! That was exactly what I was looking for :)

Post Reply