[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AppleGuide and MCL



In case anyone's interested, I have some answers to my questions about
writing AppleGuides for MCL applications.

I was not able to get window, menu or object coaches to work.
Fortunately, it is fairly easy to simulate these actions with
AppleScript coaches.

In order to do this, you need to do four things:

1. Write an AppleEvent handler which returns the rect you want to mark.
For example, this code will return a rect for a menu (specified by name):

(defvar *menubar-font* '("Chicago" 12))

(defun menu-x-start (menu-name)
  (let ((current-pos 20)) ;;starts after apple menu
    (dolist (this-menu (menubar))
      (if (string-equal (menu-title this-menu) menu-name)
        (return current-pos)
        (incf current-pos (+ 10 (string-width (menu-title this-menu)
*menubar-font*)))))))

(defmethod return-menu-loc ((a application) appleevent reply refcon)
  (declare (ignore refcon))
  (let ((menu (ae-get-parameter-char-safe appleevent)))
    (cond ((string= menu "Apple")
           (add-reply-rect reply 5 0 25 15))
          (t (let ((start (menu-x-start menu)))
               (when start
                 (add-reply-rect reply start 0 25
                                 (+ start (string-width menu
*menubar-font*)))))))))


(install-appleevent-handler :|YrAp| :|MENU| #'return-menu-loc)

This isn't as good as a real menu coach, since it doesn't mark the menu
item, but it's a reasonable substitute for now.


2. Install an 'aete' resource corresponding to the AppleEvent. This
isn't too difficult using Rez, and it allows you to test the handler
using the Script Editor.

3. Write the Applescript and save it in a file. In this case, the
applescript might be:
tell application "MyApp"
   return MenuLoc "File"
end tell

4. Define an Applescript coachmark in your guide file and use it.

I haven't had any luck with context checks, and things would be easier
if MCL supported menu, window and object coaches, so if anyone has any
ideas on getting these to work, I'd like to hear about it.

Steve