added support for QCheckBoxEvents.toggled
This commit is contained in:
parent
e372f750bd
commit
0444c087e4
@ -2,12 +2,21 @@
|
||||
|
||||
#include <QCheckBox>
|
||||
#include "src/cpp/core/NodeWidget/nodewidget.h"
|
||||
#include "napi.h"
|
||||
|
||||
class NCheckBox: public QCheckBox, public NodeWidget
|
||||
{
|
||||
NODEWIDGET_IMPLEMENTATIONS(QCheckBox)
|
||||
public:
|
||||
using QCheckBox::QCheckBox; //inherit all constructors of QCheckBox
|
||||
|
||||
void connectWidgetSignalsToEventEmitter() {
|
||||
QObject::connect(this, &QCheckBox::toggled, [=](bool checked) {
|
||||
Napi::Env env = this->emitOnNode.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
this->emitOnNode.Call({ Napi::String::New(env, "toggled"), Napi::Value::From(env, checked) });
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -19,6 +19,7 @@ import {
|
||||
QApplication,
|
||||
QClipboardMode
|
||||
} from "./index";
|
||||
import { QCheckBoxEvents } from './lib/QtWidgets/QCheckBox';
|
||||
|
||||
const path = require("path");
|
||||
|
||||
@ -33,6 +34,9 @@ const checkbox = new QCheckBox();
|
||||
checkbox.setText("Check me out?");
|
||||
checkbox.setObjectName("check");
|
||||
checkbox.setChecked(true);
|
||||
checkbox.addEventListener(QCheckBoxEvents.toggled, () => {
|
||||
console.log('checkbox was toggled!');
|
||||
})
|
||||
|
||||
const dial = new QDial();
|
||||
checkbox.setObjectName("dial");
|
||||
|
||||
@ -4,7 +4,8 @@ import { BaseWidgetEvents } from "../../core/EventWidget";
|
||||
import { NativeElement } from "../../core/Component";
|
||||
|
||||
export const QCheckBoxEvents = Object.freeze({
|
||||
...BaseWidgetEvents
|
||||
...BaseWidgetEvents,
|
||||
toggled: "toggled"
|
||||
});
|
||||
export class QCheckBox extends NodeWidget {
|
||||
native: NativeElement;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user