[comp.sys.mac.hypercard] how detect opening of message box?

keith@ac.dal.ca (03/02/90)

I'm writing a stack which does keytrapping in one of its three editable fields.
I'm using the XFCN called controlLock to turn the keytrapping on and off 
when the user goes from field to field by either tabbing or mousing. A
problem arises when the user opens the message box and keytrapping is still on.
I don't know how to detect this and turn the keytrapping off automatically.
My only solution so far is to include a button when can be used to toggle
the keytrapping manually.  I'd like a more elegant solution.  Does anyone
know how to detect opening of the message box?   Thanks.

I posted this message previously and screwed up subject name.  I don't know
how to delete messages or change the subject name.  Sorry for the 
inconvenience.      Keith

jdevoto@Apple.COM (Jeanne A. E. DeVoto) (03/03/90)

In article <1287@ac.dal.ca> keith@ac.dal.ca writes:
>I'm using the XFCN called controlLock to turn the keytrapping on and off 
>when the user goes from field to field by either tabbing or mousing. A
>problem arises when the user opens the message box and keytrapping is still on.
>I don't know how to detect this and turn the keytrapping off automatically.

There are two methods you might use. If the only way the user will show
the message box is by using the menu item or its command-key equivalent,
you can use a doMenu handler to turn off the lock:

  on doMenu theItem
    if theItem is "Message" then
      if the visible of the message is false then
         -- command to turn off lock
      else
         -- command to turn on lock
      end if
    end if
    pass doMenu -- DO NOT UNDER ANY CIRCUMSTANCES FORGET THIS!
  end doMenu

This method raises a problem if the user uses the message windoid's close
box to hide it; the keytrapping will not be restored. A way to handle this
is to use an idle handler to check the status of the message box:

  on idle
    if the visible of the message box is true then
      -- turn off lock
    else
      -- turn on lock
    end if
  end idle

Idle handlers slow responsiveness in some stacks, but they're sometimes
extremely useful.
-- 
====== jeanne a. e. devoto ========================================
 jdevoto@apple.com  |  You may not distribute this article under a
 jdevoto@well.UUCP  |  compilation copyright without my permission.
___________________________________________________________________
 Apple Computer and I are not authorized  |        CI$: 72411,165
 to speak for each other.                 |  AppleLink: SQA.TEST