[comp.sys.mac.programmer] Movable-modal dialogs

bhil@ohs.UUCP (Brian T. Hill) (07/04/90)

I recently downloaded the movable-modal WDEF from apple.com and put it into
a program of mine.  As I prepared to do so, I wondered how the user would
be able to switch applications in MultiFinder if I didn't allow them to
click outside the dialog window.  When I got the program running (I was
using THINK C 4.0 with its debugger) I found that there wasn't a problem:
MultiFinder caught the mouseclick before I got an event for it.  In fact,
I never got an event for it.  Well, that was cool, until I ran it without
the debugger.  This time, when I had the movable-modal up and I clicked on
the MultiFinder icon, I got 9 (yes, NINE) events for it!  After I got the
events (which led to 9 SysBeep() calls) it finally swapped applications.
I rebooted and the same thing happened.  The same thing happens when I
build the application to disk and run it.  The only time it doesn't happen
is when I'm using the THINK C debugger.

Why is MultiFinder giving me the mouseclick event?  Why is it giving it to
me nine times?

I know this isn't really a big problem, but I'd like to solve it before we
start our BETA sites next week.

Brian T. Hill
trACE(tm) Software Development
bhil@ohs.uunet.uu.net
bhil@ohs.uucp

jackiw@cs.swarthmore.edu (Nick Jackiw) (07/08/90)

bhil@ohs.UUCP (Brian T. Hill) writes:
> 
> Why is MultiFinder giving me the mouseclick event?  Why is it giving it to
> me nine times?

I haven't confirmed this in the case of movable modal dialogs, but when
Multifinder switches, it operates different depending upon whether or
not you are 'Multifinder Aware.' If you are not,  Multifinder has to
go through a charade to convince you to convert any private clipboard
data structure your application may use into the global desk scrap.
It does this by attempting to open a desk-accessory, and therefore sends
you mouseclicks in the menubar.  (The assumption is that your application
will convert its scrap before a desk-accessory comes up so the accessory
can use it too.) After a while of failing to convince you that a desk
accessory is coming up, Multifinder gives up and switches you out anyway.

These pseudomouseclicks are presumably what you're seeing.

The way to avoid them is to become Multifinder aware.  This is done by
toggling the appropriate bit in your SIZE resource and adding Suspend
and Resume event-handling to your event loop.  If you don't have access
to documentation describing how to do this (Programming Multifinder, 
any of a variety of technotes, or Inside Mac VI), send e-mail.



> 
> I know this isn't really a big problem, but I'd like to solve it before we
> start our BETA sites next week.
> 
> Brian T. Hill
> trACE(tm) Software Development
> bhil@ohs.uunet.uu.net
> bhil@ohs.uucp


--
-----Nicholas Jackiw [jackiw@cs.swarthmore.edu|jackiw@swarthmr.bitnet]-----
"Here is how I built this artificial mine. I snatched a female louse from the
hair of humanity. I was seen to lie with her on three successive nights, and
then I flung her into the pit."       _Maldoror_, Canto II