Re: Knowing how a Text Editing Session ended
Re: Knowing how a Text Editing Session ended
- Subject: Re: Knowing how a Text Editing Session ended
- From: Motti Shneor <email@hidden>
- Date: Thu, 22 Jul 2010 04:47:05 -0400
- Acceptlanguage: en-US
- Thread-topic: Knowing how a Text Editing Session ended
Thanks Mike --- Following your recommendation and the docs, I managed to extract the value of the @"NSTextMovement" key from the notification userInfo Dictionary, which contains just what I needed.
However, I found that my problem is a bit deeper --- I want to finish the text editing session in 2 extra "nonstandard" ways (option-Tab, and option-shift-Tab) which in our specific context mean "Tab to the field below this field" and "Tab to the field above this field". the up and down equivalents to the Tab and BackTab.
Unfortunately, the FieldEditor does not end the editing session in reacion to these key-presses, and inserts the characters into the text instead.
My Question: How can I Persuade the FieldEditor to end an Editing Session when these specific key-combinations occur? Should I override something? Is there a specific Delegate for that?
I thought that there should be something like:
- (BOOL)control:(NSControl *)control textShouldEndEditing:(NSText *)fieldEditor
Where my delegate could decide if the current input (last key pressed) should cause the FieldEditor to resign editing on this field, or not.
But this delegate is only called when Tab, BackTab, Esc or Enter/Return are pressed ---- so I don't have the chance to decide.
Any ideas?
How can I configure the FieldEditor? Any sample code known to anyone?
Thanks again!!!
On 21/07/2010, at 17:51, Mike Abdullah wrote:
Look up the docs on NSTextDidEndEditingNotification. I believe the same user info gets handed out in controlTextDidEndEditing:
On 21 Jul 2010, at 15:30, Motti Shneor wrote:
Hello Everyone.
I'm implementing a programmatic wrapper for using an NSTextField on our custom view ---
I programmatically create an NSTextField, Embed it in the super-view, then let the user type in text and as soon as the user finishes, I need to collect the typed string, plus the way the field was dismissed (Esc, Return, Tab, Back-Tab plus modification keys if any). I then release this NSTextField, until I need to create a new one.
Now --- I tried to Implement the
- (BOOL)control:(NSControl *)control textShouldEndEditing:(NSText *)fieldEditor;
and the
- (void)controlTextDidEndEditing:(NSNotification *)obj;
NSControl delegate methods , and I even get them called.
However, I don't know how to extract the REASON for the ending of the text editing session. From the input of these delegate, I can extract the FieldEditor responsible, but I don't know how to question it for the reason "I got here".
I could subclass NSTextField and implement the
-insertReturn and - insertTab methods (of NSResponder) and record the status (Still I don't know how to identify a Back-Tab or an option-Tab or an ctrl-Tab etc) but I try to refrain from subclassing NSTextField.
Any hint will be greatly appreciated!
Motti Shneor
------------------------------------------
Senior Software Engineer
Waves Audio ltd.
[mailto: email@hidden]
_______________________________________________
Cocoa-dev mailing list (email@hidden<mailto: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<http://lists.apple.com>
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden<mailto:email@hidden>
Motti Shneor
------------------------------------------
Senior Software Engineer
Waves Audio ltd.
Phone: +972-3-6084155
Mobile: +972-54-4470730
[mailto: email@hidden]
_______________________________________________
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