Touch screen text input
May 7, 2000
by Pat McClellan
Dear Handyman,
I am working on a touchscreen kiosk without a keyboard available. Is it possible to create sprites that simulate numeric keystrokes on mouseUp? The error I've been running into is on mouseUp where a variable was set to be placed in a text field, each time another button is pressed, the text is replaced by the most recent mouseUp. I need the numbers to appear in the text field sequentially.
Paul
Dear Paul,
It's been a while since I've dealt with a touchscreen situation. The touchscreen part doesn't really impact the issue you're asking about, but it seems to me that I may have opted to use mouseDown instead of mouseUp on the touchscreen. It would be good to collect some touchscreen kiosk tips.
You probably just need to alter your code a little bit. Here's a dialpad with numbers. The code is easily reused to include letters, and the button push (member swap) and sound effects are separate behaviors.
Director 7 download for Mac or Windows.
There are 2 behaviors which handle the text input. The first is applied to the text member. This behavior starts by clearing out all the text in its member. Then, when it gets a message from the input keys, it accepts the input and adds the new character onto whatever text (if any) is already in that member.
property pMem, pText
on beginSprite me
pText = ""
pMem = sprite(me.spriteNum).member
pMem.text = pText
end beginSprite
on acceptInput me, newCharacter
pText = pText & newCharacter
pMem.text = pText
end acceptInput
property pMyCharacter, pDisplaySprite
on getPropertyDescriptionList me
set pdlist to [:]
addprop pdlist, #pMyCharacter, [#comment:"Which character?", #format:#string, #default:"1"]
addprop pdlist, #pDisplaySprite, [#comment:"Which spriteNum for display?", #format:#integer, #default:18]
return pdlist
end getPropertyDescriptionList
on mouseUp me
sendSprite(pDisplaySprite, #acceptInput, pMyCharacter)
end mouseUp
As you can see, most of the code is for the gpdl handler, which lets you specify which character is assigned to that sprite. It also requires you to specify the sprite channel that the text display sprite is in. That's required in the sendSprite command that appears in the mouseUp handler. (The mouseUp can be changed to mouseDown if you want.)
That's all there is to it. Good luck with your program.
Copyright 1997-2024, Director Online. Article content copyright by respective authors.