diff --git a/doric-Qt/example/doric/engine/v8/JSValueHelper.cpp b/doric-Qt/example/doric/engine/v8/JSValueHelper.cpp index 8aee6672..e40cd67f 100644 --- a/doric-Qt/example/doric/engine/v8/JSValueHelper.cpp +++ b/doric-Qt/example/doric/engine/v8/JSValueHelper.cpp @@ -90,6 +90,8 @@ v8::Local Variant2JS(QVariant variant) { jsValue = array; } else if (variant.type() == QVariant::Int) { jsValue = v8::Number::New(isolate, variant.toDouble()); + } else if (variant.type() == QVariant::Bool) { + jsValue = v8::Boolean::New(isolate, variant.toBool()); } else if (variant.type() == QVariant::Invalid) { jsValue = v8::Undefined(isolate); } diff --git a/doric-Qt/example/doric/resources/input.qml b/doric-Qt/example/doric/resources/input.qml index 26aee6ba..fa97e502 100644 --- a/doric-Qt/example/doric/resources/input.qml +++ b/doric-Qt/example/doric/resources/input.qml @@ -67,6 +67,11 @@ TextArea { inputBridge.onTextChange(wrapper, this.text) } + onFocusChanged: { + console.log(tag, uuid + " onFocusChanged: " + this.focus) + inputBridge.onFocusChange(wrapper, this.focus) + } + property var borderWidth: 0 onBorderWidthChanged: { bg.border.width = borderWidth diff --git a/doric-Qt/example/doric/shader/DoricInputNode.cpp b/doric-Qt/example/doric/shader/DoricInputNode.cpp index eafd20a4..a2c45a9b 100644 --- a/doric-Qt/example/doric/shader/DoricInputNode.cpp +++ b/doric-Qt/example/doric/shader/DoricInputNode.cpp @@ -64,3 +64,11 @@ void DoricInputNode::onTextChange(QString text) { callJSResponse(onTextChangeId, args); } } + +void DoricInputNode::onFocusChange(bool hasFocus) { + if (!onFocusChangeId.isEmpty()) { + QVariantList args; + args.append(hasFocus); + callJSResponse(onFocusChangeId, args); + } +} diff --git a/doric-Qt/example/doric/shader/DoricInputNode.h b/doric-Qt/example/doric/shader/DoricInputNode.h index cc12171c..9b9e8186 100644 --- a/doric-Qt/example/doric/shader/DoricInputNode.h +++ b/doric-Qt/example/doric/shader/DoricInputNode.h @@ -20,6 +20,8 @@ public: QSizeF sizeThatFits(QSizeF size); void onTextChange(QString text); + + void onFocusChange(bool hasFocus); }; #endif // DORICINPUTNODE_H diff --git a/doric-Qt/example/doric/utils/DoricInputBridge.cpp b/doric-Qt/example/doric/utils/DoricInputBridge.cpp index f4861792..3f1ad365 100644 --- a/doric-Qt/example/doric/utils/DoricInputBridge.cpp +++ b/doric-Qt/example/doric/utils/DoricInputBridge.cpp @@ -11,7 +11,9 @@ void DoricInputBridge::onTextChange(QString pointer, QString text) { inputNode->onTextChange(text); } -void DoricInputBridge::onFocusChange(QString pointer) { +void DoricInputBridge::onFocusChange(QString pointer, bool hasFocus) { QObject *object = (QObject *)(pointer.toULongLong()); DoricInputNode *inputNode = dynamic_cast(object); + + inputNode->onFocusChange(hasFocus); } diff --git a/doric-Qt/example/doric/utils/DoricInputBridge.h b/doric-Qt/example/doric/utils/DoricInputBridge.h index f752232e..e1da8f90 100644 --- a/doric-Qt/example/doric/utils/DoricInputBridge.h +++ b/doric-Qt/example/doric/utils/DoricInputBridge.h @@ -15,7 +15,7 @@ public: void onTextChange(QString pointer, QString text); Q_INVOKABLE - void onFocusChange(QString pointer); + void onFocusChange(QString pointer, bool hasFocus); signals: };