Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReturnKeyType Listener #713

Closed
lscown opened this issue Sep 11, 2015 · 9 comments
Closed

ReturnKeyType Listener #713

lscown opened this issue Sep 11, 2015 · 9 comments
Milestone

Comments

@lscown
Copy link

lscown commented Sep 11, 2015

Currently you can set a ReturnKeyType on a EditableTextBase. This is great, however it's really only cosmetic at this point as you can't listen to when the element "Next" or "Done" is pressed.

Would be good to:

  • When Next is pressed, listen and then be able to focus on another textField
  • When Done is pressed, listen and then run some code
@NathanaelA

This comment was marked as abuse.

@PeterStaev
Copy link
Contributor

👍

@x4080
Copy link

x4080 commented Oct 23, 2015

Hi, and how to use this new feature ? there are no next previous button on iOS keyboard, and how to add the listener for moving to next textfield for example ?

Thanks

@x4080
Copy link

x4080 commented Oct 23, 2015

I did some trial, and maybe the best to remove owner.dismissSoftInput() in the onFocusChange and in the onEditorAction (editable-text-base.android.js) since it automatically go to the next textedit if there is any and dismiss the keyboard when it is the only textedit (on android 5, I don't know in other android version)

Havent dig in the iOS yet though

@PeterStaev
Copy link
Contributor

Try this:

<Page xmlns="http://www.nativescript.org/tns.xsd">
  <StackLayout>
    <TextField id="user-name" returnKeyType="next"  returnPress="userNameReturnPress"/>
    <TextField id="password" returnKeyType="go"  returnPress="performLogin"/>
  </StackLayout>
</Page>
import pages = require("ui/page");
import textField = require("ui/text-field");

var passwordTextField: textField.TextField

export function pageLoaded(args: observable.EventData)
{
    var page = <pages.Page>args.object;

    passwordTextField = page.getViewById<textField.TextField>("password");
}
export function userNameReturnPress(args: observable.EventData)
{
    passwordTextField.focus();
}
export function performLogin(args: observable.EventData)
{
    // Some Code
}

@x4080
Copy link

x4080 commented Oct 23, 2015

Thanks Peter,

EDIT : Using Peter sample is working great, but I still have to modify the editable-text-base.android.js like above, since using the default file from tns_modules, the keyboard is ALWAYS dismissed even in the "next" setting

@orsag
Copy link

orsag commented Mar 22, 2016

This @PeterStaev solution does not work anymore after upgrade to 1.7, userNameReturnPress is never fired. Tested on real device. Also just to focus() textfield does not show the keyboard, annoying.

@PeterStaev
Copy link
Contributor

@orsag this is because there are problems with it i the 1.7 version see #1721

@lock
Copy link

lock bot commented Aug 30, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Aug 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants