Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTextView and Click on Button



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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

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>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.