mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 03:31:45 +08:00
31 lines
862 B
TypeScript
31 lines
862 B
TypeScript
import { Page } from "tns-core-modules/ui/page";
|
|
import { TextField } from "tns-core-modules/ui/text-field";
|
|
|
|
export function setText(args) {
|
|
let page = args;
|
|
|
|
if (page.constructor.name !== "Page") {
|
|
page = args.object.page;
|
|
setTextFieldText(page, "inXml", "in xml");
|
|
}
|
|
|
|
setTextFieldText(page, "maxLenghtFromCodeBehindWithText", "from code behind");
|
|
setTextFieldText(page, "useInput", "");
|
|
setTextFieldText(page, "maxLenghtFromCodeBehind", "");
|
|
}
|
|
|
|
export function pageLoaded(args) {
|
|
const page = args.object;
|
|
setText(page);
|
|
}
|
|
|
|
function setTextFieldText(page: Page, name: string, text: string) {
|
|
const textField = <TextField>page.getViewById(name);
|
|
|
|
if (name === "maxLenghtFromCodeBehind" || name === "maxLenghtFromCodeBehindWithText") {
|
|
textField.maxLength = 3;
|
|
}
|
|
|
|
textField.text = text;
|
|
}
|