RE: Which key is down?

2001-02-22 Thread John Kiltinen

Alan Beattie <[EMAIL PROTECTED]> replied to my post on this subject as follows:

>On 21/2/01 3:19 pm, John Kiltinen at [EMAIL PROTECTED] wrote:
>
>> I have a button on a stack which, when pressed, opens an answer dialog
>> offering the user three options, "A", "B", or "C".  I would like to speed
>> up the process by allowing the experienced user to bypass the dialog by
>> holding down the key for one of these letters on the keyboard while
>> pressing the button, which will result in going directly to the chosen
>> option.
>>
>> Surely this is easily done, but I can't figure out how.  I've experimented
>> with the keyDown message, but holding a key down for awhile sends multiple
>> copies of this message, analogous to getting repeated a's while holding the
>> "a" key down when typing.  This will complicate matters.
>
>Hi John, to do this, you could try putting the following in your button
>script:
>---
>global gKeyState
>
>on mouseUp
>  switch gKeyState
>  case "a"
>-- do things associated with button "A" here
>break
>  case "b"
>-- do things associated with button "B" here
>break
>  case "c"
>-- do things associated with button "C" here
>break
>  default
>modal [your dialog name]
>break
>  end switch
>end mouseUp
>---
>and this in your card script:
>---
>global gKeyState
>local lResult
>
>on keyDown pKey
>  put pKey into gKeyState
>  if lResult is not in the pendingMessages then send "varBlank" to me in 200
>milliseconds
>  put the result into lResult
>end keyDown
>
>on varBlank
>  put empty into gKeyState
>end varBlank
>---

Thanks, Alan.  Since I get the messages to this list in the digest form, I
had already built a solution to my problem based upon the information I was
lacking that Monte Goulding gave in his post.  However it reassuring to see
that a MetaCard pro at Runrev came up with essentially the same method that
I did.  One   new thing that I learned from your script here was the
existence of the "switch" control structure.  I have not run across this
before.  (I could have used it a few weeks ago to greatly simplify a script
that needed lots of "if...then..else" controls.)

The major difference between our solutions is that I have the keyDown
handler in script for the button, and this seems to work fine on both the
Mac OS and Windows platforms.  As I mentioned, I discovered that when the
autoarm property of the button is set to true, the button can receive the
keyboard focus, but not when it is false.

Alan, you added a script for using a commandKeyDown handler to do this job:

>> I've noted that while a button does not normally accept the keyboard focus,
>> if its autoarm property is set to true, it will.  Thus, a keyDown message
>> could be sent to the button.  But my problem is that I haven't found the
>> secret of telling WHICH key is down.  (There ought to be a function that
>> gives this information, but what is it?)
>
>I think this function is on the feature request list. In the meantime if you
>want to make things easier and make your application function in a more
>standard manner you could use keyboard combinations to achieve the effect
>you want by putting something like the following in your card script:
>
>on controlKeyDown pKey -- or you could use commandKeyDown
>  switch pKey
>  case "a"
>-- do things associated with button "A" here
>break
>  case "b"
>-- do things associated with button "B" here
>break
>  case "c"
>-- do things associated with button "C" here
>break
>  default
>modal [your dialog name]
>break
>  end switch
>end controlKeyDown
>
>Cheers,
>
>Alan
>
>Alan Beattie <[EMAIL PROTECTED]> <http://www.runrev.com/>
>Runtime Revolution Limited (Formerly Cross Worlds Computing)
>Tel: +44 (0)131 672 2909.  Fax: +44 (0)1639 830 707.

This demonstrates how MetaCard, with all the generality built into it,
provides multiple ways of getting a job done.  However in my situation,
associating the command-A keystroke combination with "A" functionality
would create ambiguity.  My program gives the user the capability of
programming macro buttons which are labeled "A", "B", and "C".  There is a
button the user presses to start the programming process for any of these
buttons, and another to review the steps that are programmed already into
any of them.  There are separate buttons labeled with these letters to
execute the marcos, and

RE: Which key is down?

2001-02-22 Thread John Kiltinen

In reply to my inquiry about which key is down when a keyDown message is
sent, "Monte Goulding" <[EMAIL PROTECTED]> wrote:

>I'm not quite sure that this is the answer you want but the keydown handler
>has a parameter that is the key pressed. on keydown x will put the key
>pressed into x

Bingo!!  Thanks, Monte.  I knew this was an easy question.  I just did not
know MetaCard's syntax for passing parameters (arguments) with messages.
It is frustrating that little details like this are so hard to find in
MetaCard's documentation.

I have now worked out a strategy for coordinating keyDown and mouseUp
handlers in the script for this button that gets the job done.  (I found
that I needed to move the letter into another global variable to pass it
from the keyDown handler to the mouseUp handler as the variable "x" used to
receive the letter did not seem to work for this purpose.)

John Kiltinen

My original question:
>> I have a button on a stack which, when pressed, opens an answer dialog
>> offering the user three options, "A", "B", or "C".  I would like to speed
>> up the process by allowing the experienced user to bypass the dialog by
>> holding down the key for one of these letters on the keyboard while
>> pressing the button, which will result in going directly to the chosen
>> option.
>>
>> Surely this is easily done, but I can't figure out how.  I've experimented
>> with the keyDown message, but holding a key down for awhile sends multiple
>> copies of this message, analogous to getting repeated a's while
>> holding the
>> "a" key down when typing.  This will complicate matters.
>>
>> I've noted that while a button does not normally accept the
>> keyboard focus,
>> if its autoarm property is set to true, it will.  Thus, a keyDown message
>> could be sent to the button.  But my problem is that I haven't found the
>> secret of telling WHICH key is down.  (There ought to be a function that
>> gives this information, but what is it?)
>>
>> Assuming I can tell which key is down, will there be any problem
>> coordinating the processing of keyDown and mouseUp messages by
>> the handlers
>> for this button?
>>
>> This ought to be an easy exercise for anyone who knows MetaCard well.
>> Help, anyone?
>>
>> John Kiltinen



 John Kiltinen ([EMAIL PROTECTED])Home  Office
 Professor, Dept. of Math. & CS   Tel.(906) 228-8035 or (906) 227-1600
 Northern Michigan University Fax (906) 228-4667 or (906) 2272010
 Marquette, MI 49855 USA




Archives: http://www.mail-archive.com/metacard@lists.runrev.com/
Info: http://www.xworlds.com/metacard/mailinglist.htm
Please send bug reports to <[EMAIL PROTECTED]>, not this list.




Re: Which key is down?

2001-02-22 Thread Alan Beattie

On 21/2/01 3:19 pm, John Kiltinen at [EMAIL PROTECTED] wrote:

> I have a button on a stack which, when pressed, opens an answer dialog
> offering the user three options, "A", "B", or "C".  I would like to speed
> up the process by allowing the experienced user to bypass the dialog by
> holding down the key for one of these letters on the keyboard while
> pressing the button, which will result in going directly to the chosen
> option.
> 
> Surely this is easily done, but I can't figure out how.  I've experimented
> with the keyDown message, but holding a key down for awhile sends multiple
> copies of this message, analogous to getting repeated a's while holding the
> "a" key down when typing.  This will complicate matters.

Hi John, to do this, you could try putting the following in your button
script:
---
global gKeyState

on mouseUp
  switch gKeyState
  case "a"
-- do things associated with button "A" here
break
  case "b"
-- do things associated with button "B" here
break
  case "c"
-- do things associated with button "C" here
break
  default
modal [your dialog name]
break
  end switch
end mouseUp
---
and this in your card script:
---
global gKeyState
local lResult

on keyDown pKey
  put pKey into gKeyState
  if lResult is not in the pendingMessages then send "varBlank" to me in 200
milliseconds
  put the result into lResult
end keyDown

on varBlank
  put empty into gKeyState
end varBlank
---

> I've noted that while a button does not normally accept the keyboard focus,
> if its autoarm property is set to true, it will.  Thus, a keyDown message
> could be sent to the button.  But my problem is that I haven't found the
> secret of telling WHICH key is down.  (There ought to be a function that
> gives this information, but what is it?)

I think this function is on the feature request list. In the meantime if you
want to make things easier and make your application function in a more
standard manner you could use keyboard combinations to achieve the effect
you want by putting something like the following in your card script:

on controlKeyDown pKey -- or you could use commandKeyDown
  switch pKey
  case "a"
-- do things associated with button "A" here
break
  case "b"
-- do things associated with button "B" here
break
  case "c"
-- do things associated with button "C" here
break
  default
modal [your dialog name]
break
  end switch
end controlKeyDown

Cheers,

Alan

Alan Beattie <[EMAIL PROTECTED]> <http://www.runrev.com/>
Runtime Revolution Limited (Formerly Cross Worlds Computing)
Tel: +44 (0)131 672 2909.  Fax: +44 (0)1639 830 707.


Archives: http://www.mail-archive.com/metacard@lists.runrev.com/
Info: http://www.xworlds.com/metacard/mailinglist.htm
Please send bug reports to <[EMAIL PROTECTED]>, not this list.




Re: Which key is down?

2001-02-22 Thread Alan Beattie

On 21/2/01 3:19 pm, John Kiltinen at [EMAIL PROTECTED] wrote:

> I have a button on a stack which, when pressed, opens an answer dialog
> offering the user three options, "A", "B", or "C".  I would like to speed
> up the process by allowing the experienced user to bypass the dialog by
> holding down the key for one of these letters on the keyboard while
> pressing the button, which will result in going directly to the chosen
> option.
> 
> Surely this is easily done, but I can't figure out how.  I've experimented
> with the keyDown message, but holding a key down for awhile sends multiple
> copies of this message, analogous to getting repeated a's while holding the
> "a" key down when typing.  This will complicate matters.

Hi John, to do this, you could try putting the following in your button
script:
---
global gKeyState

on mouseUp
  switch gKeyState
  case "a"
-- do things associated with button "A" here
break
  case "b"
-- do things associated with button "B" here
break
  case "c"
-- do things associated with button "C" here
break
  default
modal [your dialog name]
break
  end switch
end mouseUp
---
and this in your card script:
---
global gKeyState
local lResult

on keyDown pKey
  put pKey into gKeyState
  if lResult is not in the pendingMessages then send "varBlank" to me in 200
milliseconds
  put the result into lResult
end keyDown

on varBlank
  put empty into gKeyState
end varBlank
---

> I've noted that while a button does not normally accept the keyboard focus,
> if its autoarm property is set to true, it will.  Thus, a keyDown message
> could be sent to the button.  But my problem is that I haven't found the
> secret of telling WHICH key is down.  (There ought to be a function that
> gives this information, but what is it?)

I think this function is on the feature request list. In the meantime if you
want to make things easier and make your application function in a more
standard manner you could use keyboard combinations to achieve the effect
you want by putting something like the following in your card script:

on controlKeyDown pKey -- or you could use commandKeyDown
  switch pKey
  case "a"
-- do things associated with button "A" here
break
  case "b"
-- do things associated with button "B" here
break
  case "c"
-- do things associated with button "C" here
break
  default
modal [your dialog name]
break
  end switch
end controlKeyDown

Cheers,

Alan

Alan Beattie <[EMAIL PROTECTED]> <http://www.runrev.com/>
Runtime Revolution Limited (Formerly Cross Worlds Computing)
Tel: +44 (0)131 672 2909.  Fax: +44 (0)1639 830 707.


Archives: http://www.mail-archive.com/metacard@lists.runrev.com/
Info: http://www.xworlds.com/metacard/mailinglist.htm
Please send bug reports to <[EMAIL PROTECTED]>, not this list.




RE: Which key is down?

2001-02-20 Thread Monte Goulding

I'm not quite sure that this is the answer you want but the keydown handler
has a parameter that is the key pressed. on keydown x will put the key
pressed into x

> I have a button on a stack which, when pressed, opens an answer dialog
> offering the user three options, "A", "B", or "C".  I would like to speed
> up the process by allowing the experienced user to bypass the dialog by
> holding down the key for one of these letters on the keyboard while
> pressing the button, which will result in going directly to the chosen
> option.
>
> Surely this is easily done, but I can't figure out how.  I've experimented
> with the keyDown message, but holding a key down for awhile sends multiple
> copies of this message, analogous to getting repeated a's while
> holding the
> "a" key down when typing.  This will complicate matters.
>
> I've noted that while a button does not normally accept the
> keyboard focus,
> if its autoarm property is set to true, it will.  Thus, a keyDown message
> could be sent to the button.  But my problem is that I haven't found the
> secret of telling WHICH key is down.  (There ought to be a function that
> gives this information, but what is it?)
>
> Assuming I can tell which key is down, will there be any problem
> coordinating the processing of keyDown and mouseUp messages by
> the handlers
> for this button?
>
> This ought to be an easy exercise for anyone who knows MetaCard well.
> Help, anyone?
>
> John Kiltinen
>
>
> 
>  John Kiltinen ([EMAIL PROTECTED])Home  Office
>  Professor, Dept. of Math. & CS   Tel.(906) 228-8035 or (906) 227-1600
>  Northern Michigan University Fax (906) 228-4667 or (906) 2272010
>  Marquette, MI 49855 USA
> 
>
>
>
> Archives: http://www.mail-archive.com/metacard@lists.runrev.com/
> Info: http://www.xworlds.com/metacard/mailinglist.htm
> Please send bug reports to <[EMAIL PROTECTED]>, not this list.
>
>


Archives: http://www.mail-archive.com/metacard@lists.runrev.com/
Info: http://www.xworlds.com/metacard/mailinglist.htm
Please send bug reports to <[EMAIL PROTECTED]>, not this list.




Which key is down?

2001-02-20 Thread John Kiltinen

I have a button on a stack which, when pressed, opens an answer dialog
offering the user three options, "A", "B", or "C".  I would like to speed
up the process by allowing the experienced user to bypass the dialog by
holding down the key for one of these letters on the keyboard while
pressing the button, which will result in going directly to the chosen
option.

Surely this is easily done, but I can't figure out how.  I've experimented
with the keyDown message, but holding a key down for awhile sends multiple
copies of this message, analogous to getting repeated a's while holding the
"a" key down when typing.  This will complicate matters.

I've noted that while a button does not normally accept the keyboard focus,
if its autoarm property is set to true, it will.  Thus, a keyDown message
could be sent to the button.  But my problem is that I haven't found the
secret of telling WHICH key is down.  (There ought to be a function that
gives this information, but what is it?)

Assuming I can tell which key is down, will there be any problem
coordinating the processing of keyDown and mouseUp messages by the handlers
for this button?

This ought to be an easy exercise for anyone who knows MetaCard well.
Help, anyone?

John Kiltinen



 John Kiltinen ([EMAIL PROTECTED])Home  Office
 Professor, Dept. of Math. & CS   Tel.(906) 228-8035 or (906) 227-1600
 Northern Michigan University Fax (906) 228-4667 or (906) 2272010
 Marquette, MI 49855 USA




Archives: http://www.mail-archive.com/metacard@lists.runrev.com/
Info: http://www.xworlds.com/metacard/mailinglist.htm
Please send bug reports to <[EMAIL PROTECTED]>, not this list.