screen keyboard

Ben Rubinstein benr_mc at cogapp.com
Thu Jun 19 13:50:30 EDT 2008


On 18/6/08 19:36, Eric Sciolli wrote:
> Hello
> I'm a teacher and I've students who needs specials keyboards to work with
> standard applications. Does someone has tried to create a screen keyboard in
> revolution to write in standard applications like Word? Perhaps using
> appleEvents?


Hi Eric,

I've done this for use with RevBrowser - we wanted a customised browser for a 
touchscreen, with the ability for users to complete forms.

The solution - at least for Mac - was to use AppleScript, with the extremely 
useful application "System Events" (provided by Apple).

Here's the function I used:

   on typeLetter tText, bShift
     put "tell application" && quote &  "System Events" & quote & return \
       into tAScom
     put "key code" && tText after tAScom
     if bShift then put " using shift down" after tAScom
     put return & "end tell" & return after tAScom
     do tAScom as applescript
   end typeLetter

But note that you send a key code, rather than the letter you want.  I made 
the keyboard out of buttons, each with a custom property for the keycode they 
should corrrespond to; the keyboard was grouped, and the group contained a 
mouseUp handler

   on mouseUp
     typeLetter (the uKeyCode of the target), stShiftStatus
   end mouseUp

I don't recall where I found the reference for keycodes, but I would expect 
Google will be your friend (if not let me know and I can reverse it back out 
of the buttons).

The problem I can foresee is about how you prevent Revolution receiving the 
keypresses.   In my project, Rev and RevBrowser are both the front-most 
application, but Rev isn't able to send keypresses into the browser (which is 
really an instance of webkit).  So Rev asked the "System Events" application 
to 'type' the keys, and since the revbrowser instance had the focus, in the 
front-most application, this worked fine.  In your case I would expect that 
the Rev app presenting the on-screen keyboard would be the front-most app, 
otherwise why did it get the mouse event - so it would probably receive the 
key event also.

Someone else might be able to provide the piece of the puzzle that lets you 
make a Rev stack appear as a floating palette - receiving mouse clicks on its 
window without actually acquiring focus or being the front-most app. 
Otherwise I think you'd have to modify the 'typeLetter' handler above so that 
it finds out which app is next-to-front, and activates that app before sending 
the message to "System Events".

Hope this helps,

- Ben




More information about the use-livecode mailing list