[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Need to insert keydown events into MCL



 
Matthew Cornell writes in a message dated Thu, 16 Apr 92 10:55:34 EDT:

MC> In trying to make incremental searches playback correctly in my
MC> fred-macros.lisp contribution I seem to need a new mechanism other
MC> than my current one, which uses RUN-FRED-COMMAND. Specifically, I want
MC> a function INSERT-KEY-EVENT that is passed a character and a list of
MC> modifiers, and makes the Mac or MCL think the user just hit those
MC> keys. For example:
MC> 
MC> (defun TEST-PLAYBACK ()
MC>   (dolist (event-item '((#\r :control) (#\m) (#\a) (#\c) (#\g :control)))
MC>     (insert-key-event (first event-item) (rest event-item))))
MC> 
MC> I looked at #_PostEvent but IM II-68 warns the modifiers will be the
MC> current ones, so I can't pass the saved ones.
MC> 

Take a look at IM IV-85. #_PPostEvent gives you a pointer to the created queue
element, which you can then use to set the modifiers. Just be sure to do this
in a without-interrupts form, otherwise the element is likely to be removed
from the queue before you alter its modifiers.

Also, I believe this is one of the places where IM is wrong. The (apparently
correct) declaration given in Apple's interfaces browser stack is this:
FUNCTION PPostEvent(eventCode: INTEGER;
                     eventMsg: LONGINT;
                      VAR qEl: EvQElPtr): OSErr;
which doesn't match IM IV, but does correspond to the _description_ given in
IM IV. If you look at OSEvents.Lisp, it seems that there was a problem either
in translating the call or in verifying its correctness. At any rate, the trap
definition is commented out. (My files are from 2.0b1p3).

Dave
--  
 --- Through FidoNet gateway node 1:16/390
David.Lamkins@p14.f640.n101.z1.fidonet.org