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/[email protected]/
Info: http://www.xworlds.com/metacard/mailinglist.htm
Please send bug reports to <[EMAIL PROTECTED]>, not this list.

Reply via email to