• 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 and Click on Button
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTextView and Click on Button


  • Subject: Re: NSTextView and Click on Button
  • From: Steve Cronin <email@hidden>
  • Date: Wed, 28 Nov 2007 21:04:49 -0600

Joshua;

Thank-you for your direct, concise and helpful answer.

I consider it a model answer in the listserve paradigm: direct, clear, including links for followup and further clarity and actually answering the posted question!

Sleep well tonight - you've burnished up your karma.

Thanks Again,
Steve

On Nov 28, 2007, at 3:49 PM, Joshua Emmons wrote:

I know there is a ton of documentation on this but if you don't know how to ask the right question you will never find the right answer... I have tried but I just can't seem to find what I'm looking for.


The question you want to ask has to do with First Responder, so I would recommend reading up on that. In addition to being a generally fascinating topic, being knowledgeable in it will pay great dividends when debugging obscure behavior in the future.

http://developer.apple.com/documentation/Cocoa/Conceptual/ CocoaFundamentals/CoreAppArchitecture/chapter_7_section_6.html
http://developer.apple.com/documentation/Cocoa/Conceptual/ EventOverview/index.html


Also of general responder interest (though maybe not to you if you're using NSTextViews?) is the field editors. It inserts itself into the responder chain and causes general confusion to new users of the cocoa text system. I don't think NSTextViews, being full- blown "heavy" text objects in and of themselves, use a field editor... but again, it's something worth knowing.

http://developer.apple.com/documentation/Cocoa/Conceptual/ TextArchitecture/Concepts/TextFieldsAndViews.html
http://developer.apple.com/documentation/Cocoa/Conceptual/ TextEditing/Tasks/FieldEditor.html


On the button click I'd like to do something like:
[myTextView textShouldEndEditing]  but that doesn't work.

I believe you'll want to call [yourWindow makeFirstResponder:nil];

http://developer.apple.com/documentation/Cocoa/Reference/ ApplicationKit/Classes/NSWindow_Class/Reference/Reference.html#// apple_ref/occ/instm/NSWindow/makeFirstResponder:

This will send a -resignFirstResponder to the current first responder (in this case, your text view) causing it to commit its changes. After that, the value should be what you expect it to be.

Cheers!
-Joshua Emmons

_______________________________________________

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


References: 
 >NSTextView and Click on Button (From: Steve Cronin <email@hidden>)
 >Re: NSTextView and Click on Button (From: Joshua Emmons <email@hidden>)

  • Prev by Date: NSPredicate and square brackets
  • Next by Date: removing item from NSTreeController or NSOutlineView
  • Previous by thread: Re: NSTextView and Click on Button
  • Next by thread: NSTrackingArea + cursorUpdate: problem
  • Index(es):
    • Date
    • Thread