• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Selected text in NSTextField
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Selected text in NSTextField


  • Subject: Re: Selected text in NSTextField
  • From: Dave Fernandes <email@hidden>
  • Date: Thu, 02 Feb 2012 19:39:38 -0500

I see. I've been having trouble forcing an NSTextField to get focus in document-modal sheets, and I wondered whether NSPanel/NSWindow should make a difference. (Experimentally it does not.)

I found on Snow Leopard that the following always worked:
[sheetController window]; // load the NIB
[sheet performSelector:@selector(makeFirstResponder:) withObject:myTextField afterDelay:0.];
[NSApp beginSheet:sheet modalForWindow:docWindow ...

On Lion, it works for some sheets, but not others (very reproducible for any given sheet). Sometimes if the performSelector delay is > 0.8 sec, it works, but not always.

The problem cases are always with NSTextField or its subclasses inside of NSTabViews.

I also tried setting the sheet's initial first responder to be the text field and then calling:
[sheet makeFirstResponder:sheet];
[sheet performSelector:@selector(selectNextKeyView:) withObject:nil afterDelay:0.];

That also works in some cases and not others on Lion. Am I trying the right things here?

On 2012-02-02, at 7:10 PM, Graham Cox wrote:

> NSPanel inherits NSWindow. If you look at the methods that NSPanel adds to NSWindow, it's really a very small set.
>
> It allows:
>
> a) the window to be a floating window
>
> b) it allows the window to not become key "unless necessary", which is very useful to prevent a floater from stealing focus away from whatever it floats over, unless the user explicitly clicks in a text field, for example.
>
> c) it allows the window to be receive events when run modally.
>
> I think there are also some minor appearance differences.
>
> That's all, so if your needs are not addressed by any of these features, you may as well use NSWindow.
>
>
> --Graham
>
>
>
>
> On 03/02/2012, at 10:51 AM, Dave Fernandes wrote:
>
>> I'm still a little unclear on when to use an NSWindow and when to use an NSPanel. I thought you used an NSPanel if you did *not* want it to become key. But for input, you do want it to become key, don't you? I'm sure I've missed some basic Cocoa 101 here, but I found the docs "clear as mud" on this.
>>
>> Dave
>


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: Selected text in NSTextField
      • From: Graham Cox <email@hidden>
References: 
 >Re: Selected text in NSTextField (From: Graham Cox <email@hidden>)
 >Re: Selected text in NSTextField (From: Quincey Morris <email@hidden>)
 >Re: Selected text in NSTextField (From: Graham Cox <email@hidden>)
 >Re: Selected text in NSTextField (From: Dave Fernandes <email@hidden>)
 >Re: Selected text in NSTextField (From: Graham Cox <email@hidden>)

  • Prev by Date: Re: Selected text in NSTextField
  • Next by Date: Re: Selected text in NSTextField
  • Previous by thread: Re: Selected text in NSTextField
  • Next by thread: Re: Selected text in NSTextField
  • Index(es):
    • Date
    • Thread