Immediate keyUp events on Mac OS X?

John M McIntosh johnmci at smalltalkconsulting.com
Fri Apr 9 04:49:49 UTC 2004


Glen, take a look at sqMacUIEvents.c
void recordKeyboardEventCarbon(EventRef event)

which handles kEventTextInputUnicodeForKeyEvent

and does a EventKeyDown, EventKeyChar, and EventKeyUp to process the  
kEventTextInputUnicodeForKeyEvent.
Alas this isn't what we really want since it doesn't quite match  
physical key down/up activity.

Right now I've on my plate a change set from Tetsuya HAYASHI   
tetha at st.rim.or.jp to rework this
a bit to solve some issues with TSM data entry and MacRoman  
translations.
Someone else earlier this year pointed out the flaw in timing here. So  
let me ask do you've some
C background and would like to compile a new VM to try a few things out?

http://developer.apple.com/documentation/Carbon/Conceptual/ 
UnderstandTextInput_TSM/tinptsm_concepts/chapter_2_section_3.html

    /*  kEventTextInputUnicodeForKeyEvent
         Required parameters:
         -->     kEventParamTextInputSendComponentInstance            
typeComponentInstance
         -->     kEventParamTextInputSendRefCon                       
typeLongInteger
         -->     kEventParamTextInputSendSLRec                        
typeIntlWritingCode
         -->     kEventParamTextInputSendText                         
typeUnicodeText
         -->     kEventParamTextInputSendKeyboardEvent                
typeEventRef
                     (This parameter is the original raw keyboard event  
that produced the
                      text.  It enables access to  
kEventParamKeyModifiers and
                      kEventParamKeyCode parameters.
                      You can also extract from this event either  
Unicodes or Mac encoding
                      characters as follows:
                             kEventParamKeyUnicodes               
typeUnicodeText
                             kEventParamKeyMacCharCodes           
typeChar (if available)
                      The kEventParamKeyUnicodes parameter of the raw  
keyboard event is
                      identical to the TextInput event's  
kEventParamTextInputSendText
                      parameter.  Note that when contents of TSM's  
bottom-line input
                      window (i.e. during typing Chinese, Korean, or  
Japanese) are confirmed,
                      the raw keyboard event's keyCode and modifiers are  
set to default values.)
     */



On Apr 8, 2004, at 9:14 PM, Glen Whitney wrote:

>
> I downloaded Squeak from SqueakLand.org a few days ago (my VM says
> it is version 3.7.2b1, and I'm running under Mac OS X 10.2.8) and
> started to play with the examples on that site. When I tried to make
> my own eToys, I was quite disappointed to see that the choices for  
> when a
> script could run (normal, paused, mouseDown, etc) did not include
> anything to do with keypresses, which would provide a richer interface
> for many potential applications.
>
> Encouraged by some examples on "Bob's Super Swiki" (e.g. a Space War
> which accepts keyboard input) and by the accessibility of all of the
> Squeak system code, I did a little hacking. I modified PasteUpMorph so  
> it
> would always say it handlesKeyboard, and then added keyUp and keyDown
> methods which simply call keyUp and keyDown scripts on a specific
> Player object I've created (so I can write those scripts with the
> eToys tile interface if I like).
>
> But now I find that when I press a key and hold it down, my keyDown
> script is called as desired. But the keyUp script is instantly called,
> and if I contiue to hold the key down, after a bit the two scripts are
> called repeatedly in rapid succession. I tried turning off keyboard
> repeat in the System Preferences, which eliminated the repetitve
> calls, but still the first keyUp was called instantly after the
> keyDown, even though I still had the key down.
>
> It is as if the keyboard repeat and such were being implemented at too
> low a level, so that from Squeak's point of view the key really had
> been pressed and released, especially since I get the multiple events
> when key repeat is on and I hold the key down for a while.
>
> Obviously what I'd like is a single keyDown event when I press and
> one keyUp when I release. I tried to search this list but couldn't find
> anything relevant, my apologies if I'm being repetitive. Does anyone
> know a way to obtain that behavior?
>
>    Thanks so much for any help you can offer,
>           Glen Whitney
>
>
>
--
======================================================================== 
===
John M. McIntosh <johnmci at smalltalkconsulting.com> 1-800-477-2659
Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
======================================================================== 
===




More information about the Squeak-dev mailing list