Re: NSPanel and stopModal - how to focus on the main window again?
Re: NSPanel and stopModal - how to focus on the main window again?
- Subject: Re: NSPanel and stopModal - how to focus on the main window again?
- From: Keith Blount <email@hidden>
- Date: Thu, 2 Dec 2004 08:29:24 -0800 (PST)
- Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys
Many thanks again for the help - I have finally found
the problem. After swapping [NSApp stopModal] didn't
work, I figured I would write a stripped down text
project with only an override of mouseDown: and a
closePanel: method so that I could show you that code
to demonstrate the problem - and found that there
wasn't one. So the problem all along lay in my
mouseDown: method, in some code I (stupidly) didn't
post. I was basically sending two mouseDown events at
the same time, doing different things, because I
missed an else... Duh.
Anyway, thanks again for the help, it did lead to my
finding the problem - sorry for not having posted more
relevant code.
All the best,
Keith
--- "Tony S. Wu" <email@hidden> wrote:
> sorry, i wrote it wrong.
> i think you need to stop modal before you close the
> window.
> so move the line [NSApp stopModal] before the order
> out method.
> if this doesn't fix it, give me some more code.
>
> Tony S. Wu
> email@hidden
>
>
>
>
> On Dec 2, 2004, at 10:20 PM, Keith Blount wrote:
>
> > Many thanks for taking the time to reply.
> >
> > Unfortunately this doesn't solve the problem. I'm
> a
> > bit confused by your first suggestion, because
> that is
> > exactly what I had in the code I provided that had
> > problems. But I tried the second one (I think I
> tried
> > it before) and it made no difference - the main
> window
> > still behaves very strangely once the panel is
> closed.
> >
> > If anyone knows how I can solve this, I would be
> very
> > grateful.
> >
> > Thanks again,
> > Keith
> >
> > --- "Tony S. Wu" <email@hidden> wrote:
> >
> >> From: Tony S. Wu <email@hidden>
> >> Subject: Re: NSPanel and stopModal - how to focus
> on
> >> the main window again?
> >> Date: Thu, 2 Dec 2004 21:52:47 +0800
> >> To: Keith Blount <email@hidden>
> >>
> >> try
> >>
> >> [resizePanel orderOut:self];
> >> [NSApp stopModal];
> >>
> >> or
> >>
> >> [NSApp stopModal];
> >> [resizePanel close];
> >>
> >>
> >> Tony S. Wu
> >> email@hidden
> >>
> >>
> >>
> >>
> >> On Dec 2, 2004, at 9:24 PM, Keith Blount wrote:
> >>
> >>> Hello,
> >>>
> >>> I want to use a modal panel for my app, but am
> >> having
> >>> some problems getting it working right, and I
> >> don't
> >>> understand why. The panel is used for resizing
> >>> pictures inside a text view.
> >>>
> >>> This is how I start my panel - this code is
> >> contained
> >>> inside the mouseDown: method of a subclass of
> >>> NSTextView, just after checking for a
> double-click
> >> on
> >>> an image:
> >>>
> >>>
> >>> [NSApp runModalForWindow:resizePanel];
> >>>
> >>> (resizePanel is a pointer to an NSPanel.)
> >>>
> >>> And this is how I end my panel (this action is
> >> also
> >>> contained in the text view subclass, and
> connected
> >> to
> >>> a button on the panel):
> >>>
> >>> - (IBAction)closeResizePanel:(id)sender
> >>> {
> >>> [resizePanel orderOut:self];
> >>> [NSApp stopModal];
> >>> }
> >>>
> >>> But the problem is that once the panel closes,
> the
> >>> main window containing the text view does not
> have
> >> the
> >>> focus properly. In fact, it acts very oddly. The
> >>> selection in the text view is still blue as
> though
> >> it
> >>> has focus, but when you type, nothing happens.
> If
> >> you
> >>> then click into the text view, the text is
> >> updated.
> >>> This continues to happen until you click onto
> the
> >>> window itself, at which point everything returns
> >> to
> >>> normal - as though the window needs to be
> reminded
> >> to
> >>> work properly. Also, whilst it is acting
> >> strangely, if
> >>> you switch to another app and then back again,
> the
> >>> main window is not visible. You have to click
> into
> >> the
> >>> menu to return everything to normal (this is not
> a
> >>> document based app).
> >>>
> >>> But if I use a sheet instead of a modal panel,
> >> like
> >>> this:
> >>>
> >>> [NSApp beginSheet:resizePanel
> >>> modalForWindow:[self window]
> >>> modalDelegate:nil
> >>> didEndSelector:nil
> >>> contextInfo:nil];
> >>>
> >>> - (IBAction)closeResizePanel:(id)sender
> >>> {
> >>> [resizePanel orderOut:self];
> >>> [NSApp endSheet:resizePanel returnCode:1];
> >>> }
> >>>
> >>> Everything works fine - the window and
> NSTextView
> >> get
> >>> the focus correctly again when the sheet is
> >> closed.
> >>> The trouble is that a sheet is no good in this
> >>> situation, as it may pop up directly over the
> >> picture
> >>> that the user is trying to resize - a panel is
> >>> required so that the user can move it around and
> >> get a
> >>> good view of the image. And the panel has to be
> >> modal
> >>> because if the user is allowed to continue using
> >> the
> >>> text view, the panel may lose the reference to
> the
> >>> image it is resizing (because the user could
> move
> >> the
> >>> image).
> >>>
> >>> I have tried everything I can think of to fix
> this
> >> -
> >>> such as doing a [[self window]
> >>> makeKeyAndOrderFront:self] in an attempt to get
> >> focus
> >>> back properly), but just cannot seem to resolve
> >> this.
> >>>
> >>> If anybody could tell me what I am doing wrong,
> I
> >>> would be very grateful.
> >>>
> >>> Many thanks,
> >>> Keith
> >>>
> >>>
> >>>
> >>> __________________________________
> >>> Do you Yahoo!?
> >>> Meet the all-new My Yahoo! - Try it today!
> >>> http://my.yahoo.com
> >>>
> >>>
> >>> _______________________________________________
> >>> Do not post admin requests to the list. They
> will
> >> be ignored.
> >>> Cocoa-dev mailing list
> >> (email@hidden)
> >>> Help/Unsubscribe/Update your Subscription:
> >>>
>
=== message truncated ===
__________________________________
Do you Yahoo!?
Read only the mail you want - Yahoo! Mail SpamGuard.
http://promotions.yahoo.com/new_mail
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden