Support clear method in QPlainTextEdit
This commit is contained in:
parent
9a7d6bc4b9
commit
58e425fd62
@ -41,3 +41,7 @@ Sets the given text to the plainTextEdit.
|
||||
#### [`plainTextEdit.toPlainText()`](https://doc.qt.io/qt-5/qplaintextedit.html#toPlainText)
|
||||
|
||||
Returns the text of the text edit as plain text.
|
||||
|
||||
#### [`plainTextEdit.clear()`](https://doc.qt.io/qt-5/qplaintextedit.html#clear)
|
||||
|
||||
Deletes all the text in the text edit.
|
||||
|
||||
@ -13,6 +13,7 @@ Napi::Object QPlainTextEditWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
Napi::Function func = DefineClass(env, CLASSNAME, {
|
||||
InstanceMethod("setPlainText",&QPlainTextEditWrap::setPlainText),
|
||||
InstanceMethod("toPlainText",&QPlainTextEditWrap::toPlainText),
|
||||
InstanceMethod("clear", &QPlainTextEditWrap::clear),
|
||||
QWIDGET_WRAPPED_METHODS_EXPORT_DEFINE(QPlainTextEditWrap)
|
||||
});
|
||||
constructor = Napi::Persistent(func);
|
||||
@ -57,4 +58,11 @@ Napi::Value QPlainTextEditWrap::toPlainText(const Napi::CallbackInfo &info){
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
return Napi::Value::From(env, this->instance->toPlainText().toStdString());
|
||||
}
|
||||
|
||||
Napi::Value QPlainTextEditWrap::clear(const Napi::CallbackInfo &info){
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
this->instance->clear();
|
||||
return env.Null();
|
||||
}
|
||||
@ -20,5 +20,6 @@ class QPlainTextEditWrap : public Napi::ObjectWrap<QPlainTextEditWrap>{
|
||||
QWIDGET_WRAPPED_METHODS_DECLARATION
|
||||
Napi::Value setPlainText(const Napi::CallbackInfo& info);
|
||||
Napi::Value toPlainText(const Napi::CallbackInfo &info);
|
||||
Napi::Value clear(const Napi::CallbackInfo &info);
|
||||
};
|
||||
|
||||
|
||||
@ -31,6 +31,7 @@ export class QLineEdit extends NodeWidget {
|
||||
this.text.bind(this);
|
||||
this.setPlaceholderText.bind(this);
|
||||
this.setReadOnly.bind(this);
|
||||
this.clear.bind(this);
|
||||
}
|
||||
setText(text: string) {
|
||||
text && this.native.setText(text);
|
||||
|
||||
@ -23,6 +23,7 @@ export class QPlainTextEdit extends NodeWidget {
|
||||
// bind member functions
|
||||
this.setPlainText.bind(this);
|
||||
this.toPlainText.bind(this);
|
||||
this.clear.bind(this);
|
||||
}
|
||||
setPlainText(text: string | number) {
|
||||
this.native.setPlainText(`${text}`);
|
||||
@ -30,4 +31,7 @@ export class QPlainTextEdit extends NodeWidget {
|
||||
toPlainText() {
|
||||
return this.native.toPlainText();
|
||||
}
|
||||
clear() {
|
||||
this.native.clear();
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user