Hi Shailendra,
It's pretty easy to do such a thing by using timeout objects. You break the
system into two objects - the key, and the display. The key object keeps
track of which character has to be put in the field and the display object
keeps track of the position of the cursor. The timeout object is set to one
second. At every second, it tells the display object to advance its cursor
position. Everytime the user presses the key, you reset the timer. I've
written two scripts which illustrate the point below. They'll probably need
some customizing and debugging to fully suit your needs.
The key script is attached to your button and the display script to your
text field. I've hard coded the sprite numbers and the key values, but they
can easily be put into a GPDL.
-- Key --
property pValues
property pDisplayField
property _keyTimer
property _currentValue
on beginSprite me
pValues = ["A", "B", "C", "1"]
pDisplayField = sprite(1)
_currentValue = 0
end beginSprite me
on mouseUp me
_keyTimer = timeOut("key").new(1000, #lockKey, me)
_currentValue = _currentValue + 1
if _currentValue > pValues.count() then _currentValue = 1
pDisplayField.setValue(pValues.getAt(_currentValue))
end mouseUp me
on lockKey me
pDisplayField.advanceCursor()
end lockKey me
-- End of key --
-- Display --
property _textMember
property _cursorPos
on beginSprite me
_textMember = sprite(me.spriteNum).member
_textMember.text = ""
_cursorPos = 1
end beginSprite me
on setValue me, vChar
_textMember.char[_cursorPos] = vChar
end setValue me
on advanceCursor me
_cursorPos = _cursorPos + 1
end advanceCursor me
-- End of display --
Hope this helps. Have a nice day.
Regards,
Pranav Negandhi
<snip>
When a user
want to type a character, for example, "b", he/she has to press a
key twice within a particular time period to get "b". If he
presses the key for a long time (say 2 seconds or more), he will
get the number printed on that particular key.
Like generally all mobile phones have number "1" on second key in
first row with characters "abc1" . I'm not able to implement timer
function properly. Please help me out.
<snip>
[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!]