|
From: Bob220867 on 18 Apr 2008 05:51 Here's a niggly little thing. So I have an editable text sprite that users put their name in but the I-beam is at the end and I'd like to hilite the text "Name" so that when they type it immediately clears it. I've used the code line sprite("myUserInput").member.selection = [0, 4] and it works...for a very short time. The selection doesn't stick. If I use on prepareFrame it is always selected but I can't put any more text in (except one character). If I use beginSprite it doesn't take. I've tried putting it in a frame script, in a sprite script, in a cast member. I'm know this is simple but I'm going round in circles Thanks
From: Mike Blaustein on 18 Apr 2008 06:01 To take a different approach, you could simply set it up to clear itself the 1st time someone starts typing in it, obviating the need for the whole selection thing. property pBeenUsed on beginSprite me pBeenUsed=0 sprite(me.spriteNum).member.text="Name" end on keyDown me if pBeenUsed=0 then pBeenUsed=1 sprite(me.spriteNum).member.text="" end if pass end
From: Bob220867 on 18 Apr 2008 08:13 I changed the member to a field member and it worked well enough. I still couldn't get it to select just the word rather than the whole field and it should have worked with the text member. Harrumph!
From: Chunick on 18 Apr 2008 09:19 I'm not sure exactly the effect you're looking for, but this may help give you some more ideas: -- behavior script attached to the text sprite property spriteNum, mem on beginSprite me mem = sprite(spriteNum).member end on enterFrame me if the keyboardFocusSprite <> spriteNum then the keyboardFocusSprite = spriteNum mem.selection = [0, mem.char.count] end if end
From: Rob Dillon on 18 Apr 2008 09:32 That's not the way that selection was intended to be used. Selection when used with a text or field member, is a function. When it is used with a castLib it is a property. If you want to get a particular string in a text or field member, then you might want to use something like this: property thisSprite property thisMember on beginSprite me thisSprite = me.spriteNum thisMember = sprite(thisSprite).member selStart = 1 selEnd = 4 put chars(member(thisMember).text,selStart,selEnd) end
|
Pages: 1 Prev: Two Qs: Retrieve time/date & projector remove "close" button Next: FileIO issues/Director 11 |