import { Color , isIOS , Page , SearchBar , TextField } from "@nativescript/core" ; import { EventData } from "@nativescript/core/data/observable" ; import { NumericKeyboard } from "nativescript-numeric-keyboard" ; import { HelloWorldModel } from "./main-view-model" ; export function pageLoaded ( args ) { let page = < Page > args . object ; page . bindingContext = new HelloWorldModel ( ) ; const textField = < TextField > page . getViewById ( "defaultPluginKeyboard" ) ; new NumericKeyboard ( ) . decorate ( { textField : textField , returnKeyTitle : "Go!" , locale : "en_US" , noDecimals : true , noIpadInputBar : true , returnKeyButtonBackgroundColor : new Color ( "red" ) } ) ; if ( isIOS ) { const searchBar = < SearchBar > page . getViewById ( "searchBar" ) ; searchBar . on ( "textChange" , ( args ) => { let sb = < SearchBar > args . object ; console . log ( "searchBar, text entered: " + sb . text ) ; } ) ; const textFieldContainerSubviews = searchBar . ios . subviews . objectAtIndex ( 0 ) . subviews ; if ( textFieldContainerSubviews . count > 1 ) { new NumericKeyboard ( ) . decorate ( { textField : textFieldContainerSubviews . objectAtIndex ( 1 ) , noDecimals : true , noIpadInputBar : true , onReturnKeyPressed : ( ) : boolean => { console . log ( "onReturnKeyPressed" ) ; return true ; } } ) ; } } } export function textChange ( args ) { console . log ( "textChange" ) ; } export function returnPress ( args ) { console . log ( "returnPress" ) ; } export function onMyTextLoaded ( args ) { args . object . on ( "textChange" , ( args ) => { let numkey = < TextField > args . object ; console . log ( "onMyTextLoaded, text entered: " + numkey . text ) ; } ) ; } export function onMyTextLoadedPluginCode ( args ) { args . object . on ( "textChange" , ( args ) => { let numkey = < TextField > args . object ; console . log ( "onMyTextLoadedPluginCode, text entered: " + numkey . text ) ; } ) ; } export function onMyTextLoadedPluginView ( args ) { args . object . on ( "textChange" , ( args ) => { let numkey = < TextField > args . object ; console . log ( "onMyTextLoadedPluginCode, text entered: " + numkey . text ) ; } ) ; }