Erik Phalet <[EMAIL PROTECTED]> wrote:
> the first behaviour I need for this field goes like, when the
> user just types "30404", the result should be "00:03:04:04"
...
> is it possible to select all the text in a field at beginsprite
Hi Erik,
Assuming that you mean #field and not #text:
property spriteNum
on beginSprite(me)
tField = sprite(spriteNum).member
the keyboardFocusSprite = spriteNum
the selStart = 0
the selEnd = the number of chars in field tField
end
> the second behaviour I need goes like, when the user places his cursor p.e.
> between the third and the fourth digit and types "12321", the result should
> be "00:01:23:21"
> so I must not insert but replace digits, and here I am lost.
on keyDown(me)
case the keycode of
48, 115,116,119,121, 123,124,125,126:
-- TAB, page keys, arrow keys
pass
51, 117:
-- backspace, delete: ignore
end case
tStart = the selStart
if tStart > 11 then
-- The insertion point is at the end
exit
end if
if ((tStart + 1) mod 3) then
-- Overwrite the next character
the selEnd = tStart + 1
else
-- Jump over the ":" character (every third character)
the selStart = tStart + 1
the selEnd = tStart + 2
end if
if "0123456789" contains the key then
-- Only allow numbers
pass
end if
end keyDown
This second handler takes priority over your beginSprite requirement, so you
will have to modify it so that it fits your specifications.
Cheers,
James
[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/lingo-l.cgi To post messages to the list, email
[EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED]). Lingo-L is for
learning and helping with programming Lingo. Thanks!]