Title: [FR] easier way to override native view creation · Issue #5456 · NativeScript/NativeScript · GitHub
Open Graph Title: [FR] easier way to override native view creation · Issue #5456 · NativeScript/NativeScript
X Title: [FR] easier way to override native view creation · Issue #5456 · NativeScript/NativeScript
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...
Open Graph 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 te...
X 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 te...
Opengraph URL: https://github.com/NativeScript/NativeScript/issues/5456
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[FR] easier way to override native view creation","articleBody":"This is on android (but the request might also be for iOS)\r\n\r\nI am trying to modify the textfield to handle back pressed when the soft keyboard is shown.\r\nI want to make it so that it also blurs the textfield.\r\n\r\nOn android you need to override ```dispatchKeyEventPreIme``` on the ```EditText``` as shown [here](https://stackoverflow.com/questions/3940127/intercept-back-button-from-soft-keyboard)\r\n\r\nSo do that i can simply create a custom ```EditText``` android class.\r\nThen i need to subclass nativescript TextField class to override the ```createNativeView```\r\nI tested it and it works great.\r\nThe 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.\r\n\r\nThere is a simple fix, and it would be a good practice for all classes, which to have class method like \r\n``` protected newNativeView(): android.widget.EditText``` (textfield example) which would be called inside the ```createNativeView```.\r\nThat way any subclass could return its own subclass of ```android.widget.EditText```\r\n\r\nDoing that for all widgets would make it dead easy to add native functionalities which require overriding native functions.","author":{"url":"https://github.com/farfromrefug","@type":"Person","name":"farfromrefug"},"datePublished":"2018-02-22T15:46:35.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/5456/NativeScript/issues/5456"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:61e4bbb7-ef63-b8fb-7834-6130712f72bd |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B206:25FEC4:2F9DA19:413F74B:6973C8F2 |
| html-safe-nonce | 4f9953ad7a1c778f4ee7c7e946f4bb220a825f78a0da43b88d6812551decd0f6 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMjA2OjI1RkVDNDoyRjlEQTE5OjQxM0Y3NEI6Njk3M0M4RjIiLCJ2aXNpdG9yX2lkIjoiNzcxOTYzNTQ1Nzc5NjE5NjU5NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 1cf0457c465ce3c199030a256a9013f1ea37c753cca03f9c0858dfe8ea86b64f |
| hovercard-subject-tag | issue:299403449 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/NativeScript/NativeScript/5456/issue_layout |
| twitter:image | https://opengraph.githubassets.com/8ad5b2667b19280e02171b6a6cb03dd43ba9a88defaff9f8f01a9b4cbdaded63/NativeScript/NativeScript/issues/5456 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/8ad5b2667b19280e02171b6a6cb03dd43ba9a88defaff9f8f01a9b4cbdaded63/NativeScript/NativeScript/issues/5456 |
| og:image:alt | 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 te... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | farfromrefug |
| hostname | github.com |
| expected-hostname | github.com |
| None | cee21c7b1ab632710d33905bc72e5e9e520eab75c9a12e16c2ce9e8f6e031e06 |
| turbo-cache-control | no-preview |
| go-import | github.com/NativeScript/NativeScript git https://github.com/NativeScript/NativeScript.git |
| octolytics-dimension-user_id | 7392261 |
| octolytics-dimension-user_login | NativeScript |
| octolytics-dimension-repository_id | 31492490 |
| octolytics-dimension-repository_nwo | NativeScript/NativeScript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 31492490 |
| octolytics-dimension-repository_network_root_nwo | NativeScript/NativeScript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | f5f1d4f67b002a74550b90d5c1c0f0899544c742 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width