Search code examples
javascriptnativescript

Nativescript - Use Enter key to submit a prompt dialog


I can't figure out how to make the keyboard enter key press the ok button or run a function. When I display a prompt dialog, the enter key hides the keyboard on ios and/or makes another line on android. It should press the ok button instead.

Any help appreciated

Thanks Jacklin

var dialogsModule = require("ui/dialogs");

dialogsModule.prompt({
    message: "Add new activity:",
    cancelButtonText: "Cancel",
    okButtonText: "Add"
})

Solution

  • Newest question with response How do I change the return key type of a text from a prompt in NativeScript?

    This is still the first result in Google for certain keywords so I'm pasting here the answer but it's not good news:

    Unfortunately you can not do that. As of today {N} do not expose the underlaying native view for dialogs so it's not possible to override natively.

    You will have to build the complete custom dialog yourself to achieve what you are looking for.