Path: utzoo!mnetor!uunet!seismo!sundc!pitstop!sun!decwrl!nsc!voder!apple!darin
From: darin@Apple.COM (Darin Adler)
Newsgroups: comp.sys.mac.programmer
Subject: Re: MultiFinder switch bug with custom WDEFs
Message-ID: <9364@apple.Apple.Com>
Date: 7 May 88 07:21:04 GMT
References: <242@uvabick.UUCP> <8700@apple.Apple.Com> <2887@midas.TEK.COM> <9332@apple.Apple.Com> <2770@polya.STANFORD.EDU>
Reply-To: darin@apple.UUCP (Darin Adler)
Organization: Apple
Lines: 39
Keywords: MultiFinder doesn't allow switching when it thinks it sees a dBoxProc

In article <2770@polya.STANFORD.EDU> kaufman@polya.stanford.edu (Marc T. Kaufman) writes:
> One of the main reasons for using modal dialogs where modeless dialogs
> would do, is the availability of the Dialog Manager for handling most of
> the buttons, switches, and events.  If a dialog is modeless, you cannot
> use IsDialogEvent, NewDialog, GetNewDialog, or the ModalDialog event filter.

Absolutely untrue! IsDialogEvent, NewDialog, and GetNewDialog can all be used
with modeless dialogs. Note that for a modeless dialog, you create the dialog
and then return to the main event loop. Some of the events you receive from
GetNextEvent or WaitNextEvent need to be passed to the dialog manager. After
gettin an event, you call IsDialogEvent. If that returns TRUE, then you call
DialogSelect for the event. This is the equivalent of what ModalDialog does for
modal dialogs. Note that you can do the same filtering that you would do in a
ModalDialog event filter just before calling DialogSelect. I even sometimes use
the same dialog filter for both modal and modeless dialogs like this:

    modal case:

	... NewDialog ...

	ModalDialog(itemHit, @DialogFilter);

    modeless case:

	... NewDialog ... {fall back to main event loop}

	... GetNextEvent(everyEvent, event) ...
	IF IsDialogEvent(event) THEN BEGIN
	    dialog := FrontWindow;
	    hitSomething := FALSE;
	    IF WindowPeek(dialog)^.windowKind = dialogKind THEN
		hitSomething := DialogFilter(dialog, event, itemHit);
	    IF NOT hitSomething THEN
		hitSomething := DialogSelect(event, dialog, itemHit);
	... {handle hits here} ...
	END;
-- 
Darin Adler						AppleLink:Adler4
UUCP: {sun,voder,nsc,mtxinu,dual}!apple!darin	  CSNET: darin@Apple.com