[comp.sys.mac.hypercard] what was the last key hit?

biling@ucscd.UCSC.EDU (Doug Rosener) (02/17/89)

Does anyone know how to findout what was the most recent key that was
hit?.

I am using an xcmd, but I don't have the source code for it.  The xcmd
terminates when any key is hit, but I want my handler to know which key
it was.

Thanks in advance

Doug Rosener

carterbk@apple.com (Bryan 'STAKMan' Carter) (02/18/89)

In article <6391@saturn.ucsc.edu> biling@ucscd.UCSC.EDU (Doug Rosener) 
writes:
> Does anyone know how to findout what was the most recent key that was
> hit?.

There is an XFCN called InKey() which, when called in a handler such as 
idle or a repeat loop, will let you know which key was hit.  InKey() puts 
the  ASCii equivelent of the alphaNumeric character in "it".  It would be 
called as follows:

on idle
   get InKey()
   put it
   pass idle
end idle

As far as getting you the XFCN, I am unaware of the possibilities of 
sending files via NewsNet!!


'STAKMan'aging,
Bryan K. 'STAKMan' Carter
President, Apple HyperCard User Group
Author/Scriptor of S.T.A.R.S.
Stack Tracking And Retrieval System
All opinions/views/comments are mine!!
<<<There are two of every kind of snow flake in the world, it just depends 
upon who's second grade class your in.>>>

annie@cs.swarthmore.edu (Annie Fetter) (02/21/89)

In article <708@internal.Apple.COM> carterbk@apple.com (Bryan 'STAKMan' Carter) writes:
> There is an XFCN called InKey() which, when called in a handler such as 
> 
> Bryan K. 'STAKMan' Carter

I have this XFCN, and will send it to anyone who wants it. Just send me a note
and I'll get it out.  If you don't have this XFCN, you need it.  Just think,
BASIC had this, why shouldn't HyperTalk?


-- 
       Annie Fetter           |      annie@cs.swarthmore.edu    |    
VGP-Department of Mathematics |      fetter@swarthmr.bitnet     |  For Office
    Swarthmore College        |  ...!rutgers!bpa!swatsun!annie  |   Use Only
   Swarthmore, PA 19081       |         (215) 328-8225          |   

casseres@Apple.COM (David Casseres) (02/22/89)

In article <2460@ilium.cs.swarthmore.edu> annie@cs.swarthmore.edu (Annie Fetter) writes:
>In article <708@internal.Apple.COM> carterbk@apple.com (Bryan 'STAKMan' Carter) writes:
>> There is an XFCN called InKey() which, when called in a handler such as 
>> 
>> Bryan K. 'STAKMan' Carter
>
>I have this XFCN, and will send it to anyone who wants it. Just send me a note
>and I'll get it out.  If you don't have this XFCN, you need it.  Just think,
>BASIC had this, why shouldn't HyperTalk?

I tried using InKey, but there are two problems.  First, InKey not only
tells me what the last character was, it also removes the event from the
queue.  That means if it isn't a character I want to do something with,
I must either do something with it anyway or throw it away.  Now, I could
write an XCMD to put it back on the queue, or I could write a replacement
for InKey that would leave the character on the queue, but I would still have
the second problem: the Idle handler doesn't get called often enough to
guarantee that I catch all the characters, and in fact it's easy to type
fast enough that this is a problem.

I think HyperCard itself should have a system message called On Keystroke.
Are you listening, Dan?

David Casseres

dan@Apple.COM (Dan Allen) (02/22/89)

In article <735@internal.Apple.COM> casseres@Apple.COM (David Casseres) writes:
>I think HyperCard itself should have a system message called On Keystroke.
>Are you listening, Dan?

I agree!  I inquired about this myself recently, wondering why any
keystroke is not a message.  Bill A. told me that they were going to do
it but that the overhead was too slow: typing was unacceptable.  I can
buy that.

The good news is that we are speeding up HyperTalk, so we are going to
test the performance again and maybe now we can send a message with
every keystroke... no guarantees, but let's hope!

Dan

GFX@PSUVM.BITNET (02/26/89)

In article <735@internal.Apple.COM>, casseres@Apple.COM (David Casseres) says:

>the Idle handler doesn't get called often enough to
>guarantee that I catch all the characters, and in fact it's easy to type
>fast enough that this is a problem.

Can't agree more.  It makes Inkey() and TrapReturn unreliable.  Any
suggestion out there?  I would be very happy to hear about a way to
capture reliably <RETURN> keys typed in a field.  My problem is that
I have a column of fields used to input the parameters for some kind
of operation.  I would like the <RETURN> key to behave as if it were
a <TAB> key.  TrapReturn catches some, but not nearly all of them.
Stephane