nodeguy/src/lib/QtWidgets/QLineEdit.ts
Atul R 6035b5d038
Re arrange folders to make more sense (#180)
* Re-arranged qtgui and core

* Re arranges qt widgets
2019-11-08 20:33:17 +01:00

52 lines
1.5 KiB
TypeScript

import addon from '../utils/addon';
import { NodeWidget } from './QWidget';
import { BaseWidgetEvents } from '../core/EventWidget';
import { NativeElement } from '../core/Component';
export const QLineEditEvents = Object.freeze({
...BaseWidgetEvents,
cursorPositionChanged: 'cursorPositionChanged',
editingFinished: 'editingFinished',
inputRejected: 'inputRejected',
returnPressed: 'returnPressed',
selectionChanged: 'selectionChanged',
textChanged: 'textChanged',
textEdited: 'textEdited',
});
export class QLineEdit extends NodeWidget {
native: NativeElement;
placeholderText?: string;
constructor(parent?: NodeWidget) {
let native;
if (parent) {
native = new addon.QLineEdit(parent.native);
} else {
native = new addon.QLineEdit();
}
super(native);
this.native = native;
this.nodeParent = parent;
}
setText(text: string): void {
// react:✓
text && this.native.setText(text);
}
text(): string {
// react:✓
return this.native.text();
}
setPlaceholderText(text: string): void {
// react:✓ TODO://getter
this.placeholderText = text;
this.native.setPlaceholderText(text);
}
setReadOnly(isReadOnly: boolean): void {
// react:✓ TODO://getter
this.native.setReadOnly(isReadOnly);
}
clear(): void {
// react:✓
this.native.clear();
}
}