wired things about NSApp Modal
-
Hi all ,
I got some wired things. Can someone give me some explanation ?
I got a Window A. I call [NSApp RunModalForWindow] to make it modal
Inside Window A's notification method , windowDidBecomeKey , I call [NSApp
abortModal] ,What I want to do is that not letting the window showing up.
But the window is still showing up as Modal window ,but when you switch the
app to others and then switch back , the window disappeared , and the Modal
stops.
Is this wired? I can't figure out why it acts like this? -
On 2008 Feb, 08, at 18:50, cai qin wrote:> Is this wired? I can't figure out why it acts like this?
I'm not sure I understand you 100%, but it sounds like maybe the code
containing -abortModal is not running because the app is in a modal
state from which it does not recover until you switch to another app.
Use an NSLog() to confirm that.
Of course, what is really weird is that you are sending -
runModalForWindow: specifying a window that you do not want to show.
I would suggest not showing (running modal) the window in the first
place, then you would not have to worry about getting rid of it in the
second place. -
On Feb 9, 2008, at 04:50, cai qin wrote:> I got some wired things. Can someone give me some explanation ?
>
> I got a Window A. I call [NSApp RunModalForWindow] to make it modal
> Inside Window A's notification method , windowDidBecomeKey , I call
> [NSApp
> abortModal] ,What I want to do is that not letting the window
> showing up.
> But the window is still showing up as Modal window ,but when you
> switch the
> app to others and then switch back , the window disappeared , and
> the Modal
> stops.
> Is this wired? I can't figure out why it acts like this?
What are you trying to do? why do you run a window modally if you
don't want it to show?
Best Regards,
Nir Soffer -
On 8 Feb '08, at 6:50 PM, cai qin wrote:> I got a Window A. I call [NSApp RunModalForWindow] to make it modal
> Inside Window A's notification method , windowDidBecomeKey , I call
> [NSApp
> abortModal] ,What I want to do is that not letting the window
> showing up.
> But the window is still showing up as Modal window ,but when you
> switch the
> app to others and then switch back , the window disappeared , and
> the Modal
> stops.
Did you tell the window to become key? Perhaps it's not becoming key
until you switch to another app and then back. You could set a
breakpoint in your windowDidBecomeKey method to find out.
Overall, though, it's better to avoid modal windows if possible. They
can be frustrating or confusing to the user. Use sheets or modeless
panels instead.
âJens -
---------- Forwarded message ----------
From: cai qin <celery01...>
Date: 2008-2-11 12:26
Subject: Re: wired things about NSApp Modal
To: Jens Alfke <jens...>
Thank you for the rely.
In fact , I'm going to use the ocTest to build some automatic test.
So I get a Modal Window , I want to show it first ,then close it
automatically . I'm sure that the windowDidBecomeKey method did get called.
Perhaps I didn't describe my question clearly , which leads to some
misunderstanding.
Now I 'm using a NSTimer to call another method to abort Modal and close the
window. It works well.
But I still want to figure out why these wired things happened which like I
described in my question.
2008/2/9, Jens Alfke <jens...>:>
>
> On 8 Feb '08, at 6:50 PM, cai qin wrote:
>
>> I got a Window A. I call [NSApp RunModalForWindow] to make it modal
>> Inside Window A's notification method , windowDidBecomeKey , I call
>> [NSApp
>> abortModal] ,What I want to do is that not letting the window
>> showing up.
>> But the window is still showing up as Modal window ,but when you
>> switch the
>> app to others and then switch back , the window disappeared , and
>> the Modal
>> stops.
>
> Did you tell the window to become key? Perhaps it's not becoming key
> until you switch to another app and then back. You could set a
> breakpoint in your windowDidBecomeKey method to find out.
>
> Overall, though, it's better to avoid modal windows if possible. They
> can be frustrating or confusing to the user. Use sheets or modeless
> panels instead.
>
> ¡ªJens


