[comp.sys.mac.programmer] posting events with modifiers

ifocs9d@aucs.uucp (Rick Giles) (08/25/90)

I want to post a keyDown event with a given modifiers value. Can this
be done after PostEvent or PPostEvent? Thanks.

Rick Giles

Bitnet:   FRGILES@Acadia.ca
Internet: FRGILES%Acadia.BITNET@CUNYVM.CUNY.EDU 
UUCP:     uunet!dalcs!aucs!ifocs9d 

jmunkki@hila.hut.fi (Juri Munkki) (08/25/90)

In article <1990Aug24.232505.4970@aucs.uucp> ifocs9d@aucs.uucp (Rick Giles) writes:
>I want to post a keyDown event with a given modifiers value. Can this
>be done after PostEvent or PPostEvent? Thanks.

It can be done with Enqueue. Here's one that does a cmd-shift-9:

	EvQEl	thePress;

	thePress.qType=evType;
	thePress.evtQWhat=keyDown;
	thePress.evtQMessage='9';
	thePress.evtQWhen=TickCount();
	thePress.evtQModifiers=cmdKey+shiftKey;
	Enqueue(&thePress,GetEvQHdr());

I haven't tried PPostEvent, but it might also be able to do the trick. Why
haven't you tried? Why do people insist on asking the net before trying to
write maybe ten lines of code to test their ideas?

   ___________________________________________________________________________
  / Juri Munkki	    /  Helsinki University of Technology   /  Wind  /   HP S /
 / jmunkki@hut.fi  /  Computing Center Macintosh Support  /  Surf  /   48 X /
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

carlton@draco (Mike Carlton) (08/28/90)

In article <1990Aug25.094039.17415@santra.uucp> jmunkki@hila.hut.fi (Juri Munkki) writes:
>In article <1990Aug24.232505.4970@aucs.uucp> ifocs9d@aucs.uucp (Rick Giles) writes:
>>I want to post a keyDown event with a given modifiers value. Can this
>>be done after PostEvent or PPostEvent? Thanks.
>
>It can be done with Enqueue. Here's one that does a cmd-shift-9:
>
... code omitted ...
>
>I haven't tried PPostEvent, but it might also be able to do the trick. Why
>haven't you tried? Why do people insist on asking the net before trying to
>write maybe ten lines of code to test their ideas?
>
>   ___________________________________________________________________________
>  / Juri Munkki	    /  Helsinki University of Technology   /  Wind  /   HP S /
> / jmunkki@hut.fi  /  Computing Center Macintosh Support  /  Surf  /   48 X /
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I think PPostEvent is probably more appropriate than Enqueue (although 
PPostEvent will likely just call Enqueue for you, but at least you can let
it fill in the queue type and so on).

Here is pseudo-code that I use (email if you want actual running c code):
	Fill in the keypress in the event record
	PPostEvent the event record, a event queue element pointer is returned
	Munge the modifier's field.
	You're all done.

This is documented in IM IV, OS Event chapter.  Curiously enough, PPostEvent 
doesn't seem to be in the IM Cross-Reference or in the index to volume IV.

Cheers,
Mike Carlton, UC Berkeley Computer Science	  	  	   	  ~
carlton@ernie.berkeley.edu    ...!ucbvax!ernie!carlton 		 	Manana