handle response

This commit is contained in:
王劲鹏
2021-06-02 11:26:11 +08:00
committed by osborn
parent a0a6ebf50d
commit 80301837c3
8 changed files with 52 additions and 3 deletions

View File

@@ -20,8 +20,17 @@ QQuickItem *DoricDraggableNode::build() {
void DoricDraggableNode::blend(QQuickItem *view, QString name,
QJsonValue prop) {
if (name == "onDrag") {
onDrag = prop.toString();
onDragFunction = prop.toString();
} else {
DoricStackNode::blend(view, name, prop);
}
}
void DoricDraggableNode::onDrag(double x, double y) {
getLayouts()->setMarginLeft(x);
getLayouts()->setMarginTop(y);
QVariantList args;
args.append(x);
args.append(y);
callJSResponse(onDragFunction, args);
}

View File

@@ -8,7 +8,7 @@
class DORIC_EXPORT DoricDraggableNode : public DoricStackNode {
private:
QString onDrag;
QString onDragFunction;
public:
using DoricStackNode::DoricStackNode;
@@ -16,6 +16,8 @@ public:
QQuickItem *build() override;
virtual void blend(QQuickItem *view, QString name, QJsonValue prop) override;
void onDrag(double x, double y);
};
#endif // DORICDRAGGABLENODE_H