开发者

setValue: Not Getting Called for Textfield Before Enabled State Changes

I've a radio button with 2 options each of which has an associated textfields. I want to disable the textfield of the radio button that is not selected when the selected button changes.

If I modify the textfield and immediately after select the radio button, the setValue: is called only for radio's key path, but not for the textfield's key path.

The change in enabled state overrides the last value in the textf开发者_StackOverflow社区ield causing the changed value to be lost.

Here're some snapshots:

Original state

setValue: Not Getting Called for Textfield Before Enabled State Changes

After modifying:

setValue: Not Getting Called for Textfield Before Enabled State Changes

After changing the radio button (top textfield is reverted):

setValue: Not Getting Called for Textfield Before Enabled State Changes


I had a very similar problem a couple years ago and found a good solution here. Hopefully this will work for you.


I think the behavior you're seeing is correct. If the user is disabling a text field in the middle of an editing session, the edits should cancel.

If you were using selective disclosure instead of selective enablement, which would mean hiding the text fields which don't apply instead of disabling them, it makes more sense to discard edits to a control that's about to disappear. It's reasonable to apply the same here.


Setting the text field control to Continuous should cause it to setValue: after every keypress.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜