Page 1 of 1

simulate keyboard

Posted: Fri Nov 28, 2008 3:13 pm
by Ron Zellner
I'm creating a class resource to be used on a tablet PC. Part of the task is to enter text in a field. I guess the best approach is a graphic of the keyboard with buttons placed over the keys and then use a general script like:

Put the short name of me after field "Title"

Etc.

Then use button highlite and some audio 'click' for feedback.

Is there a better approach or an existing resource that I'm not aware of?

First idea is fine

Posted: Sat Nov 29, 2008 5:55 am
by Ron Zellner
The basic idea worked- I grouped all the buttons that cover the keys on a graphic of a keyboard and this is the code for the group (only one place that needs editing):

Code: Select all

on mouseUp
   play audioClip "snd_click.wav"
   put the short name of the target after field "TitleContent"
end mouseUp
Any further suggestions are welcome- Now need to switch between upper/lower case. Not sure if I just want to duplicate the whole group, or modify each key to have a dual name ( A a ). Then use an IF to test for the caps lock and select, e.g.

Code: Select all

put word 2 of the name of the target after field "TitleContent"
This way seems easier to maintain & edit.

Posted: Sat Nov 29, 2008 10:24 am
by malte
Hi Ron,

you might want to look up toUpper() and toLower() in the dictionary. If you check for the shiftkey, you can do something lke:

put toUpper(the short name of the target) into fld "myField"

Hope that helps,

Malte

Posted: Sat Nov 29, 2008 4:18 pm
by Ron Zellner
Malte,

Yes, thanks! That helps very much. Very efficient way to do it.

Another elusive feature: is there a way to determine where the text insertion point (cursor) is in a field? I need to have the delete button delete the character to the left of that point. I can delete at the end of the line, but not inside it. I can also delete selected text, but cannot put new text at the insertion point.

Code: Select all

on mouseUp
   play audioClip "snd_click.wav"
   if the selectedText of field "TitleContent" ="" then
      delete last character of field "TitleContent"
   else
      delete the selectedChunk     
   end if
end mouseUp
If you remember, we purchased Arcade Engine a few years ago and I wanted to mention that the student using it for simulating coin puzzles has completed her dissertation on problem solving strategies and graduated. It all worked well and allowed for a more realistic simulation. Thanks again for your help on that.

Posted: Sun Nov 30, 2008 8:40 pm
by malte
Hi Ron,

you will need to play with the selectedChunk of the field. if word 2 of the selectedChunk > word 4 of the selectedChunk of the field, you know there is no selection active and the insertionpoint is after char (word 2 of the selectedChunk of the field).

Glad to here the coin project worked out! Is that available somewhere? I'd be really curious to see it.

All the best,


Malte

Posted: Mon Dec 01, 2008 5:49 am
by Ron Zellner
Malte,
Thanks again! that was the insight that I needed, I didn't realize I could get a value for 'selected chunk' if there was nothing selected, but the line:

Put the selectedchunk of field "TitleContent"

Produced (as you indicated) the following:

char 86 to 85 of field 1

So this was then the simple solution for the delete button:

Code: Select all

on mouseUp
   play audioClip "snd_click.wav"
   
   if the selectedText of field "TitleContent" ="" then  --no text has been selected
      Put word 4 of the selectedchunk of field "TitleContent" into ThePoint  -- identifies the character to the left of the insertion point
      delete  character ThePoint of field "TitleContent"  -- deletes the character to the left of the insertion point
   else
      delete the selectedChunk 
   end if
end mouseUp
Likewise, the code for the text keys becomes:

Code: Select all

Put word 4 of the selectedchunk of field "TitleContent" into ThePoint  
put toLower(the label of the target) after character ThePoint of  field "TitleContent"
This is great, solves the final problem.

The coin problem is part of a large stack that has passwords, data collection, subject randomization, etc. I'll see if I can break out the Coin card and edit it so it will work out of context.