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 also buttons labeled with these letters and a prime
mark to run the series of steps in reverse. The "Program a Macro" and
"Review a Macro" buttons are the ones that bring up a dialog box that ask
which of the macros the user wants to program or review. The user now can
bypass the dialog box which asks this question by holding down the key for
the letter while pressing either the "Program a Macro" or "Review a Macro"
button.
If my program were to respond to a command-A, the user could reasonably
assume that this meant either to program macro button A, review macro
button A, or execute macro button A. I think it is best to keep these
different actions identified with the separate buttons on screen rather
than key modifiers.
But these are the thoughts of a newbie software developer. Do any of you
experienced developers have thoughts on keyboard vs. mouse access to
functionality in a situation like this where the user would have to
remember which of three functions associated with the letter "A" the
command-A keystroke combination meant?
John Kiltinen
PS: Clearly this last issue I raise here is not a specific MetaCard issue
but rather is of interest in the context of software design in greater
generality. Is this an appropriate topic for discussion on the MetaCard
list?
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
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/[email protected]/
Info: http://www.xworlds.com/metacard/mailinglist.htm
Please send bug reports to <[EMAIL PROTECTED]>, not this list.