FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[FR] easier way to override native view creation · Issue #5456 · NativeScript/NativeScript · GitHub

[FR] easier way to override native view creation #5456

Description

This is on android (but the request might also be for iOS)

I am trying to modify the textfield to handle back pressed when the soft keyboard is shown.
I want to make it so that it also blurs the textfield.

On android you need to override dispatchKeyEventPreIme on the EditText as shown here

So do that i can simply create a custom EditText android class.
Then i need to subclass nativescript TextField class to override the createNativeView
I tested it and it works great.
The issue is that the createNativeView in textfield do more than just returning a new EditText. It also create the events. So it means that i need to copy all that code back into my custom class.

There is a simple fix, and it would be a good practice for all classes, which to have class method like
protected newNativeView(): android.widget.EditText (textfield example) which would be called inside the createNativeView.
That way any subclass could return its own subclass of android.widget.EditText

Doing that for all widgets would make it dead easy to add native functionalities which require overriding native functions.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL