textShouldEndEditing or textDidEndEditing
textShouldEndEditing or textDidEndEditing
- Subject: textShouldEndEditing or textDidEndEditing
- From: Deivy Petrescu <email@hidden>
- Date: Mon, 10 Jan 2011 16:29:10 -0500
I am stumped.
Tried everything but did not succeed.
The goal is to know when the user leaves a text field and to retrieve the value of this field.
I was not able to get it right.
I get both information, but not correctly
Here is what I got from Xcode help:
----------
textShouldEndEditing:
Performs validation on the receiver’s new value.
- (BOOL)textShouldEndEditing:(NSText *)textObject
Parameters
textObject
The text object requesting permission to end editing.
Return Value
YES if the new value is valid; otherwise NO.
Discussion
This method validates the receiver's new value using the NSCell method isEntryAcceptable:. If the new value is valid and the delegate responds to control:textShouldEndEditing:, invokes that method and returns the result, in addition beeping if the delegate returns NO. See the NSControl class specification for more information on the text delegate method.
Availability
• Available in Mac OS X v10.0 and later.
------------
and
------------
textDidEndEditing:
Handles an end of editing.
- (void)textDidEndEditing:(NSNotification *)aNotification
Parameters
aNotification
The notification that editing has ended.
Discussion
After validating the new value, posts an NSControlTextDidEndEditingNotification to the default notification center. This posting causes the receiver’s delegate to receive acontrolTextDidEndEditing: message. After this message, sends endEditing: to the receiver’ cell and handles the key that caused editing to end:
• If the user ended editing by pressing Return, this method tries to send the receiver’s action to its target; if unsuccessful, it sends performKeyEquivalent: to its NSView (for example, to handle the default button on a panel); if that also fails, the receiver simply selects its text.
• If the user ended editing by pressing Tab or Shift-Tab, the receiver tries to have its NSWindowobject select its next or previous key view, using the NSWindow methodselectKeyViewFollowingView: or selectKeyViewPrecedingView:. If unsuccessful in doing this, the receiver simply selects its text.
See the NSControl class specification for more information on the text delegate method.
Availability
• Available in Mac OS X v10.0 and later.
------------
Mine code:
on thisHandlerFillsField_(sender)
set otexto to nome as string --nome is the contents of the field
log otexto
if sender's textShouldEndEditing_() = true then
---->the above line is wrong. Although I dod get it right when user leaves field.
if otexto = "" then ddok("Put a name in here")
end if
end thisHandlerFillsField_
Thanks for any help.
Deivy Petrescu
email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
applescriptobjc-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden