• 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: NSTextView question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTextView question


  • Subject: Re: NSTextView question
  • From: Rudi Sherry <email@hidden>
  • Date: Thu, 16 Mar 2006 15:34:09 -0800

On Mar 16, 2006, at 3:17 PM, Rudi Sherry wrote:


On Mar 16, 2006, at 12:41 PM, Ricky Sharp wrote:


It may also be possible to set the first responder to the field/ view. That may be enough to end editing. Also, the keyboard focus will not be "stolen".


If it really takes setting the first responder to nil, you may want to consider getting the next responder. And, if that next responder isn't the view, set it. This will keep users of full- keyboard access happy.

I tried makeFirstResponder: nil and that didn't work -- subsequent calls to [ mTextField stringValue ] returned the old value. I debugged and found that makeFirstResponder: is returning YES, but the responder isn't changing (this is typed into the email as I look at the source on another computer, so there may be typos but it is the code line for line):


NSResponder *before = [ window firstResponder ];
if ( [ window makeFirstResponder: nil ] )
{
   NSResponder *after = [ window firstResponder ];
   if ( after == before )
      NSLog( @"same responder as before" ); // <--- gets here
}


Then I tried setting it to the next responder (which was the window controller):


NSResponder *before = [ window firstResponder ]; // = the textField
NSResponder *next = [ before nextResponder ]; // = window controller
if ( [ window makeFirstResponder: next ] )
{
NSResponder *after = [ window firstResponder ]; // = window controller
if ( after == before )
NSLog( @"same responder as before" ); // does not get here
if ( after == next )
NSLog( @"have new responder" ); // <--- gets here
}


... but the stringValue is not the changed value -- it's still the old value!

I'm going to set the window controller to be the textField delegate and see if textDidEndEditing is called at any time; other than that, any suggestions?

Oops, I misspoke but I still don't understand why it's not working.... the "before" variable above, set as [ window firstResponder ], is the window itself not the mTextField... but that still doesn't explain anything.


I set the window controller to be the delegate of mTextField, but its textDidEndEditing is never called. When I hit <return> in the text field, -[NSTextField textDidEndEditing] is called (I have a breakpoint at the generic delegate).

This is so confusing... I figured after over two years of Cocoa programming I had it all figured out ;)



_______________________________________________
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


References: 
 >Re: NSTextView question (From: Matt Neuburg <email@hidden>)
 >Re: NSTextView question (From: Ricky Sharp <email@hidden>)
 >Re: NSTextView question (From: Rudi Sherry <email@hidden>)

  • Prev by Date: Re: NSTextView question
  • Next by Date: Re: saving jpegs
  • Previous by thread: Re: NSTextView question
  • Next by thread: Re: NSTextView question
  • Index(es):
    • Date
    • Thread