Problem in getting stringValue from NSSecureTextField
I have a password field of type NSSecureTextField
say passwordField
and a NSButton
. I have assigned return key as key equivalent for the button action triggering. After pressing the button I get user entered text as [passwordField stringValue]
this will give the correct value only, when user press return key after entering his password but not when user clicks on the button through mou开发者_运维技巧se. In the latter case it will give nil value. I have tried hard to find the problem but no use. If anybody knows what is going wrong, please help me.
Regards ypk
EDIT: This is observed only in 10.5 and works fine on 10.6.
Try checking Continuous on the text field in Interface Builder. Also make sure Action is set as Sent On End Editing.
I've had a similar problem. For me, it turned out that the focus was not correctly set on the text field. Calling [window makeFirstResponder: textfield]
after a timeout of 0.5 seconds solved it.
I usually explicitly call [window makeFirstResponder:nil
as one of the first lines in my button click events to ensure the Sent On End Editing
event is called.
精彩评论