0

I've been trying to do a generic validation mechanism for EntryElements using MonoTouch.Dialogs and I thought that the delegate ShouldReturn could help me to do that but it looks that I was wrong.

If I create a simple EntryElement like this:

new RootElement {
    new Section {
        new EntryElement(string.Empty, string.Empty, null),
        new EntryElement(string.Empty, string.Empty, null)
    }
}

When I test it and entering text in the first entry element and press next everything works as expected and we move to the next entry element field.

Well, as soon as I set the first entry element to something like this:

var entry = new EntryElement(string.Empty, string.Empty, null);
entry.ShouldReturn += () => true;

The "Next" functionality in the input keyboard doesn't work.

Am I missing something or I did understand wrongly the workings of EntryElement.ShouldReturn?

1 Answer 1

0

The EntryElement.SouldReturn event is just a proxy for the underlying UITextField.ShouldReturn event. Even if EntryElement lacks documentation for ShouldReturn, you can refer to UITextField doc

To me, it looks like you should be able to use ShouldReturn for validation, but if you want the Next button to keep working, I'd return false.

entry.ShouldReturn += () => {
    //Validate
    return false;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.