Eureka: Performing an action by keyboard return key

Created on 10 Jan 2017  路  1Comment  路  Source: xmartlabs/Eureka

Without Eureka, one would implement the UITextFieldDelegate.textFieldShouldReturn() delegate function to perform an action directly from the keyboard. It looks like Eureka already implements this function and simply ends editing without letting me execute my own code at this moment.

How would I go and implement this using Eureka without requiring people to tap a ButtonRow?

Most helpful comment

Problem solved. After doing some code rereading and finally realizing that FormViewController actually implements UITextFieldDelegate.textFieldShouldReturn() by forwarding execution to its own FormViewController.textInputShouldReturn() function, I could simply override this function. In my case I used the form row tag to determine on which return event to act:

override func textInputShouldReturn<T>(_ textInput: UITextInput, cell: Cell<T>) -> Bool {
    if cell.row.tag == "some_tag" {
        // action here
    }
    return super.textInputShouldReturn(textInput, cell: cell)
}

Putting this here in case someone will encounter the same thing, thanks for this library 馃憤

>All comments

Problem solved. After doing some code rereading and finally realizing that FormViewController actually implements UITextFieldDelegate.textFieldShouldReturn() by forwarding execution to its own FormViewController.textInputShouldReturn() function, I could simply override this function. In my case I used the form row tag to determine on which return event to act:

override func textInputShouldReturn<T>(_ textInput: UITextInput, cell: Cell<T>) -> Bool {
    if cell.row.tag == "some_tag" {
        // action here
    }
    return super.textInputShouldReturn(textInput, cell: cell)
}

Putting this here in case someone will encounter the same thing, thanks for this library 馃憤

Was this page helpful?
0 / 5 - 0 ratings