Adds plaintext c++ functions
This commit is contained in:
parent
ed3085f88f
commit
65becffd52
@ -11,6 +11,7 @@ Napi::Object QPlainTextEditWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
Napi::HandleScope scope(env);
|
||||
char CLASSNAME[] = "QPlainTextEdit";
|
||||
Napi::Function func = DefineClass(env, CLASSNAME, {
|
||||
InstanceMethod("setPlainText",&QPlainTextEditWrap::setPlainText),
|
||||
QWIDGET_WRAPPED_METHODS_EXPORT_DEFINE(QPlainTextEditWrap)
|
||||
});
|
||||
constructor = Napi::Persistent(func);
|
||||
@ -41,4 +42,12 @@ QPlainTextEditWrap::QPlainTextEditWrap(const Napi::CallbackInfo& info): Napi::Ob
|
||||
|
||||
QPlainTextEditWrap::~QPlainTextEditWrap() {
|
||||
delete this->instance;
|
||||
}
|
||||
}
|
||||
|
||||
Napi::Value QPlainTextEditWrap::setPlainText(const Napi::CallbackInfo& info){
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
Napi::String plainText = info[0].As<Napi::String>();
|
||||
this->instance->setPlainText(plainText.Utf8Value().c_str());
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
@ -18,6 +18,6 @@ class QPlainTextEditWrap : public Napi::ObjectWrap<QPlainTextEditWrap>{
|
||||
//wrapped methods
|
||||
|
||||
QWIDGET_WRAPPED_METHODS_DECLARATION
|
||||
|
||||
Napi::Value setPlainText(const Napi::CallbackInfo& info);
|
||||
};
|
||||
|
||||
|
||||
11
src/demo.ts
11
src/demo.ts
@ -9,9 +9,10 @@ import {
|
||||
FlexLayout,
|
||||
QWidget,
|
||||
QIcon,
|
||||
QPlainTextEdit
|
||||
} from "./index";
|
||||
|
||||
const path = require('path');
|
||||
const path = require("path");
|
||||
|
||||
const win = new QMainWindow();
|
||||
|
||||
@ -32,7 +33,9 @@ button.setText("Push Push Push!");
|
||||
button.setObjectName("btn");
|
||||
button.setFlat(true);
|
||||
|
||||
const icon = new QIcon(path.resolve(__dirname, '../extras/assets/start_icon.png'));
|
||||
const icon = new QIcon(
|
||||
path.resolve(__dirname, "../extras/assets/start_icon.png")
|
||||
);
|
||||
button.setIcon(icon);
|
||||
|
||||
const progressbar = new QProgressBar();
|
||||
@ -46,6 +49,9 @@ radioButton.setText("Roger that!");
|
||||
const rootView = new QWidget();
|
||||
rootView.setObjectName("root");
|
||||
rootView.setLayout(new FlexLayout());
|
||||
const textEdit = new QPlainTextEdit();
|
||||
textEdit.setPlainText("Hello");
|
||||
|
||||
if (rootView.layout) {
|
||||
rootView.layout.addWidget(label);
|
||||
rootView.layout.addWidget(checkbox);
|
||||
@ -53,6 +59,7 @@ if (rootView.layout) {
|
||||
rootView.layout.addWidget(lineEdit);
|
||||
rootView.layout.addWidget(button);
|
||||
rootView.layout.addWidget(progressbar);
|
||||
rootView.layout.addWidget(textEdit);
|
||||
}
|
||||
|
||||
win.setCentralWidget(rootView);
|
||||
|
||||
@ -15,7 +15,10 @@ export { QMainWindow, QMainWindowEvents } from "./lib/QtWidgets/QMainWindow";
|
||||
export { QProgressBar, QProgressBarEvents } from "./lib/QtWidgets/QProgressBar";
|
||||
export { QPushButton, QPushButtonEvents } from "./lib/QtWidgets/QPushButton";
|
||||
export { QRadioButton, QRadioButtonEvents } from "./lib/QtWidgets/QRadioButton";
|
||||
export { QPlainTextEdit } from "./lib/QtWidgets/QPlainTextEdit";
|
||||
export {
|
||||
QPlainTextEdit,
|
||||
QPlainTextEditEvents
|
||||
} from "./lib/QtWidgets/QPlainTextEdit";
|
||||
// Layouts:
|
||||
export { QGridLayout } from "./lib/QtWidgets/QGridLayout";
|
||||
export { FlexLayout } from "./lib/core/FlexLayout";
|
||||
|
||||
@ -3,9 +3,9 @@ import { NodeWidget } from "../../QtGui/QWidget";
|
||||
import { BaseWidgetEvents } from "../../core/EventWidget";
|
||||
import { NativeElement } from "../../core/Component";
|
||||
|
||||
// export const QPlainTextEditEvents = Object.freeze({
|
||||
// ...BaseWidgetEvents
|
||||
// });
|
||||
export const QPlainTextEditEvents = Object.freeze({
|
||||
...BaseWidgetEvents
|
||||
});
|
||||
export class QPlainTextEdit extends NodeWidget {
|
||||
native: NativeElement;
|
||||
constructor(parent?: NodeWidget) {
|
||||
@ -19,9 +19,9 @@ export class QPlainTextEdit extends NodeWidget {
|
||||
this.native = native;
|
||||
this.parent = parent;
|
||||
// bind member functions
|
||||
this.setText.bind(this);
|
||||
this.setPlainText.bind(this);
|
||||
}
|
||||
setText(text: string | number) {
|
||||
this.native.setText(`${text}`);
|
||||
setPlainText(text: string | number) {
|
||||
this.native.setPlainText(`${text}`);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user