fix click order

This commit is contained in:
王劲鹏 2021-04-06 16:14:43 +08:00 committed by osborn
parent e4527f7f39
commit a2c0a34a8a
11 changed files with 21 additions and 12 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.14.2, 2021-04-06T10:55:52. -->
<!-- Written by QtCreator 4.14.2, 2021-04-06T14:14:11. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>

View File

@ -62,6 +62,7 @@ v8::Local<v8::Value> String2JS(std::string string) {
v8::Local<v8::Value> Variant2JS(QVariant variant) {
v8::Isolate *isolate = v8::Isolate::GetCurrent();
v8::EscapableHandleScope handle_scope(isolate);
v8::Local<v8::Context> context = isolate->GetEnteredOrMicrotaskContext();
v8::Local<v8::Value> jsValue;
if (variant.type() == QVariant::String) {
@ -78,7 +79,14 @@ v8::Local<v8::Value> Variant2JS(QVariant variant) {
QString strJson(doc.toJson(QJsonDocument::Compact));
jsValue = String2JS(strJson.toUtf8().constData());
} else if (variant.type() == QVariant::StringList) {
qDebug() << "";
QStringList list = variant.toStringList();
v8::Handle<v8::Array> array = v8::Array::New(isolate, list.size());
for (int i = 0; i != list.size(); i++) {
v8::Local<v8::Value> value = NewV8String(list.at(i).toUtf8().constData());
auto result = array->Set(context, i, value);
result.ToChecked();
}
jsValue = array;
}
return handle_scope.Escape(jsValue);
}

View File

@ -5,7 +5,7 @@ import "util.mjs" as Util
import "gravity.mjs" as Gravity
Rectangle {
property int wrapper: 0
property var wrapper
property var uuid: Util.uuidv4()
property int childrenRectWidth: childrenRect.width

View File

@ -11,7 +11,7 @@ QQuickItem *DoricHLayoutNode::build() {
}
QQuickItem *item = qobject_cast<QQuickItem *>(component.create());
item->setProperty("wrapper", (qint64)this);
item->setProperty("wrapper", QString::number((qint64)this));
return item;
}

View File

@ -11,7 +11,7 @@ QQuickItem *DoricStackNode::build() {
}
QQuickItem *item = qobject_cast<QQuickItem *>(component.create());
item->setProperty("wrapper", (qint64)this);
item->setProperty("wrapper", QString::number((qint64)this));
return item;
}

View File

@ -12,7 +12,8 @@ QQuickItem *DoricTextNode::build() {
}
QQuickItem *item = qobject_cast<QQuickItem *>(component.create());
item->setProperty("wrapper", (qint64)this);
item->setProperty("wrapper", QString::number((qint64)this));
return item;
}

View File

@ -11,7 +11,7 @@ QQuickItem *DoricVLayoutNode::build() {
}
QQuickItem *item = qobject_cast<QQuickItem *>(component.create());
item->setProperty("wrapper", (qint64)this);
item->setProperty("wrapper", QString::number((qint64)this));
return item;
}

View File

@ -128,7 +128,7 @@ QList<QString> DoricViewNode::getIdList() {
DoricViewNode *viewNode = this;
do {
ids.append(viewNode->mId);
ids.insert(0, viewNode->mId);
viewNode = viewNode->mSuperNode;
} while (viewNode != nullptr);

View File

@ -21,7 +21,7 @@ class DoricViewNode : public DoricContextHolder {
protected:
QQuickItem *mView;
DoricSuperNode *mSuperNode;
DoricSuperNode *mSuperNode = nullptr;
virtual QQuickItem *build() = 0;

View File

@ -3,8 +3,8 @@
DoricMouseAreaBridge::DoricMouseAreaBridge(QObject *parent) : QObject(parent) {}
void DoricMouseAreaBridge::onClick(qint64 pointer) {
QObject *object = (QObject *)(pointer);
void DoricMouseAreaBridge::onClick(QString pointer) {
QObject *object = (QObject *)(pointer.toULongLong());
DoricViewNode *viewNode = dynamic_cast<DoricViewNode *>(object);
viewNode->onClick();
}

View File

@ -10,7 +10,7 @@ public:
explicit DoricMouseAreaBridge(QObject *parent = nullptr);
Q_INVOKABLE
void onClick(qint64 pointer);
void onClick(QString pointer);
signals:
};