Article View: comp.sys.mac.oop.powerplant
Article #63Re: Closing an LGADialog programmatically
From: Eric Albert
Date: Sun, 29 Oct 2000 22:24
Date: Sun, 29 Oct 2000 22:24
71 lines
3488 bytes
3488 bytes
In article <291020001117102847%mjg@mac.com>, Joey Gray <mjg@mac.com>
wrote:
> In article <ejalbert-3C7D94.05135229102000@nntp.stanford.edu>, Eric
> Albert <ejalbert@stanford.edu> wrote:
>
> > In my application, I have an StDialogHandler that opens an LGADialog.
> > That dialog contains a button that, when clicked, creates another
> > StDialogHandler that opens another LGADialog (yes, I know that nested
> > dialogs are a poor UI). When that second dialog closes, I want the
> > first dialog to close as well, but I can't get that to happen. I've
> > tried all kinds of things:
> >
> > -calling BroadcastMessage(msg_OK, nil);
> > -calling mOKButton->SimulateHotSpotClick();
> > -calling DoClose();
> > -calling ((StDialogHandler *)
> > GetSuperCommander())->ListenToMessage(msg_OK, NULL)
> >
> > among others, and not one of them closes that first dialog (OK, DoClose
> > does, but not correctly). How do I get this code block to work?
> >
> > ---
> > StDialogHandler handler(kSecondDialogID, this);
> > MyDialog *dialog = dynamic_cast<MyDialog *>(handler.GetDialog());
> > ThrowIfNil_(dialog);
> >
> > MessageT message;
> > dialog->Show();
> > do {
> > handler.DoDialog();
> > } while(message != msg_OK && message != msg_Cancel);
> >
> > if (message == msg_OK) {
> > // Close the current dialog as well, but how?
> > ...???...
> > }
>
> it's been a while since i've done this, but wouldn't your code look
> something like this:
>
> {
> StDialogHandler outerHandler( whatever... );
>
> do {
> message = outerHandler.DoDialog();
> if (message == msg_OpenOtherDialog) {
> StDialogHandler innerHandler( whatever... );
>
> // deal with the inner dialog here...
> message = msg_OK; // or msg_Cancel...whatever...
> }
> } while (message != msg_OK && message != msg_Cancel);
> }
>
> you could deal with the inner dialog in an entirely different method
> (which is what i would do) but still set the "message" variable for the
> outer dialog, after having dealt with the inner dialog, such that you
> exit your while loop cleanly.
That's not all that ideal, because it requires the class that includes
the StDialogHandler for the first dialog to know about the second, and
I'd rather not do that -- it makes that part of the code a good bit
harder to maintain. It would work, but I'm hoping there's a better
solution.
-Eric
--
Eric Albert ejalbert@stanford.edu
http://www.stanford.edu/~ejalbert/
Technical Details
Message-ID:
<ejalbert-AE5652.14240329102000@nntp.stanford.edu>Path:
arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!sn-xit-03!supernews.com!logbridge.uoregon.edu!newsfeed.stanford.edu!nntp.stanford.edu!ejalbertReferences:
<ejalbert-3C7D94.05135229102000@nntp.stanford.edu> <291020001117102847%mjg@mac.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10bcce,b84d30989c34ff62 X-Google-Attributes: gid10bcce,public X-Google-Thread: f7f77,b84d30989c34ff62 X-Google-Attributes: gidf7f77,public X-Google-Thread: f635e,b84d30989c34ff62 X-Google-Attributes: gidf635e,public X-Google-ArrivalTime: 2000-10-29 14:30:11 PST Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!sn-xit-03!supernews.com!logbridge.uoregon.edu!newsfeed.stanford.edu!nntp.stanford.edu!ejalbert From: Eric Albert <ejalbert@stanford.edu> Newsgroups: comp.sys.mac.oop.powerplant,codewarrior.mac,comp.sys.mac.programmer.codewarrior Subject: Re: Closing an LGADialog programmatically Date: Sun, 29 Oct 2000 14:24:03 -0800 Lines: 71 Message-ID: <ejalbert-AE5652.14240329102000@nntp.stanford.edu> References: <ejalbert-3C7D94.05135229102000@nntp.stanford.edu> <291020001117102847%mjg@mac.com> NNTP-Posting-Host: rivendell.stanford.edu User-Agent: MT-NewsWatcher/3.0 (PPC)