Added echoMode to QLineEdit (#187)
This commit is contained in:
parent
21e5e78876
commit
88cd9d430f
@ -25,6 +25,7 @@ class QLineEditWrap : public Napi::ObjectWrap<QLineEditWrap> {
|
||||
Napi::Value setPlaceholderText(const Napi::CallbackInfo& info);
|
||||
Napi::Value setReadOnly(const Napi::CallbackInfo& info);
|
||||
Napi::Value clear(const Napi::CallbackInfo& info);
|
||||
Napi::Value setEchoMode(const Napi::CallbackInfo& info);
|
||||
|
||||
QWIDGET_WRAPPED_METHODS_DECLARATION
|
||||
};
|
||||
|
||||
@ -18,6 +18,7 @@ Napi::Object QLineEditWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
InstanceMethod("text", &QLineEditWrap::text),
|
||||
InstanceMethod("setReadOnly", &QLineEditWrap::setReadOnly),
|
||||
InstanceMethod("clear", &QLineEditWrap::clear),
|
||||
InstanceMethod("setEchoMode", &QLineEditWrap::setEchoMode),
|
||||
QWIDGET_WRAPPED_METHODS_EXPORT_DEFINE(QLineEditWrap)});
|
||||
constructor = Napi::Persistent(func);
|
||||
exports.Set(CLASSNAME, func);
|
||||
@ -81,9 +82,19 @@ Napi::Value QLineEditWrap::setPlaceholderText(const Napi::CallbackInfo& info) {
|
||||
this->instance->setPlaceholderText(text.Utf8Value().c_str());
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
Napi::Value QLineEditWrap::clear(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
this->instance->clear();
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
Napi::Value QLineEditWrap::setEchoMode(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
Napi::Number mode = info[0].As<Napi::Number>();
|
||||
this->instance->setEchoMode(
|
||||
static_cast<QLineEdit::EchoMode>(mode.Int32Value()));
|
||||
return env.Null();
|
||||
}
|
||||
@ -23,7 +23,7 @@ export { QWidget, QWidgetEvents } from './lib/QtWidgets/QWidget';
|
||||
export { QCheckBox, QCheckBoxEvents } from './lib/QtWidgets/QCheckBox';
|
||||
export { QLabel, QLabelEvents } from './lib/QtWidgets/QLabel';
|
||||
export { QDial, QDialEvents } from './lib/QtWidgets/QDial';
|
||||
export { QLineEdit, QLineEditEvents } from './lib/QtWidgets/QLineEdit';
|
||||
export { QLineEdit, QLineEditEvents, EchoMode } from './lib/QtWidgets/QLineEdit';
|
||||
export { QMainWindow, QMainWindowEvents } from './lib/QtWidgets/QMainWindow';
|
||||
export { QProgressBar, QProgressBarEvents } from './lib/QtWidgets/QProgressBar';
|
||||
export { QPushButton, QPushButtonEvents } from './lib/QtWidgets/QPushButton';
|
||||
|
||||
@ -3,6 +3,12 @@ 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',
|
||||
@ -48,4 +54,7 @@ export class QLineEdit extends NodeWidget {
|
||||
// react:✓
|
||||
this.native.clear();
|
||||
}
|
||||
setEchoMode(mode: EchoMode): void {
|
||||
this.native.setEchoMode(mode);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user