nodeguy/src/lib/QtWidgets/QLineEdit.ts
Atul R c90b2cb3ce
QTreeWidget PR (#277)
* Added the beginning of QTreeWidget and QTreeWidgetItem

* Fixed garbage collection

* Fixed garbage collection

* Rewrote the constructor for QTreeWidgetItem

* Code cleanup

* Fixed up the QTreeWidgetItem constructor to accept only a string list of columns. Code cleanup

* Add setHeaderHidden to QTreeWidget

* Started adding signals to QTreeWidget

* Started adding signals to QTreeWidget

* Started adding signals to QTreeWidget

* Added TreeWidget back to main.cpp

* Added more functions to QTreeWidgetItem and QPlainTextEdit

* linting and cleanup

* parenting fix

* Fixes garbage collection for treewidget items
2019-12-18 17:36:44 +05:30

61 lines
1.6 KiB
TypeScript

import addon from '../utils/addon';
import { NodeWidget } from './QWidget';
import { BaseWidgetEvents } from '../core/EventWidget';
import { NativeElement } from '../core/Component';
export enum EchoMode {
Normal,
NoEcho,
Password,
PasswordEchoOnEdit,
}
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.setNodeParent(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();
}
setEchoMode(mode: EchoMode): void {
this.native.setEchoMode(mode);
}
}