import addon from '../utils/addon'; import { NodeWidget, QWidgetSignals } from './QWidget'; import { NativeElement } from '../core/Component'; export enum EchoMode { Normal, NoEcho, Password, PasswordEchoOnEdit, } export interface QLineEditSignals extends QWidgetSignals { cursorPositionChanged: (oldPos: number, newPos: number) => void; editingFinished: () => void; inputRejected: () => void; returnPressed: () => void; selectionChanged: () => void; textChanged: (text: string) => void; textEdited: (text: string) => void; } export class QLineEdit extends NodeWidget { native: NativeElement; constructor(); constructor(parent: NodeWidget); constructor(parent?: NodeWidget) { let native; if (parent) { native = new addon.QLineEdit(parent.native); } else { native = new addon.QLineEdit(); } super(native); this.native = native; this.setNodeParent(parent); } setText(text: string): void { text && this.native.setText(text); } text(): string { return this.native.text(); } setPlaceholderText(text: string): void { this.native.setPlaceholderText(text); } placeholderText(): string { return this.property('placeholderText').toString(); } setReadOnly(isReadOnly: boolean): void { this.native.setReadOnly(isReadOnly); } isReadOnly(): boolean { return this.property('readOnly').toBool(); } clear(): void { this.native.clear(); } setEchoMode(mode: EchoMode): void { this.native.setEchoMode(mode); } }