add on focus change
This commit is contained in:
		| @@ -90,6 +90,8 @@ v8::Local<v8::Value> Variant2JS(QVariant variant) { | |||||||
|     jsValue = array; |     jsValue = array; | ||||||
|   } else if (variant.type() == QVariant::Int) { |   } else if (variant.type() == QVariant::Int) { | ||||||
|     jsValue = v8::Number::New(isolate, variant.toDouble()); |     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) { |   } else if (variant.type() == QVariant::Invalid) { | ||||||
|     jsValue = v8::Undefined(isolate); |     jsValue = v8::Undefined(isolate); | ||||||
|   } |   } | ||||||
|   | |||||||
| @@ -67,6 +67,11 @@ TextArea { | |||||||
|         inputBridge.onTextChange(wrapper, this.text) |         inputBridge.onTextChange(wrapper, this.text) | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     onFocusChanged: { | ||||||
|  |         console.log(tag, uuid + " onFocusChanged: " + this.focus) | ||||||
|  |         inputBridge.onFocusChange(wrapper, this.focus) | ||||||
|  |     } | ||||||
|  |  | ||||||
|     property var borderWidth: 0 |     property var borderWidth: 0 | ||||||
|     onBorderWidthChanged: { |     onBorderWidthChanged: { | ||||||
|         bg.border.width = borderWidth |         bg.border.width = borderWidth | ||||||
|   | |||||||
| @@ -64,3 +64,11 @@ void DoricInputNode::onTextChange(QString text) { | |||||||
|     callJSResponse(onTextChangeId, args); |     callJSResponse(onTextChangeId, args); | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | void DoricInputNode::onFocusChange(bool hasFocus) { | ||||||
|  |   if (!onFocusChangeId.isEmpty()) { | ||||||
|  |     QVariantList args; | ||||||
|  |     args.append(hasFocus); | ||||||
|  |     callJSResponse(onFocusChangeId, args); | ||||||
|  |   } | ||||||
|  | } | ||||||
|   | |||||||
| @@ -20,6 +20,8 @@ public: | |||||||
|   QSizeF sizeThatFits(QSizeF size); |   QSizeF sizeThatFits(QSizeF size); | ||||||
|  |  | ||||||
|   void onTextChange(QString text); |   void onTextChange(QString text); | ||||||
|  |  | ||||||
|  |   void onFocusChange(bool hasFocus); | ||||||
| }; | }; | ||||||
|  |  | ||||||
| #endif // DORICINPUTNODE_H | #endif // DORICINPUTNODE_H | ||||||
|   | |||||||
| @@ -11,7 +11,9 @@ void DoricInputBridge::onTextChange(QString pointer, QString text) { | |||||||
|   inputNode->onTextChange(text); |   inputNode->onTextChange(text); | ||||||
| } | } | ||||||
|  |  | ||||||
| void DoricInputBridge::onFocusChange(QString pointer) { | void DoricInputBridge::onFocusChange(QString pointer, bool hasFocus) { | ||||||
|   QObject *object = (QObject *)(pointer.toULongLong()); |   QObject *object = (QObject *)(pointer.toULongLong()); | ||||||
|   DoricInputNode *inputNode = dynamic_cast<DoricInputNode *>(object); |   DoricInputNode *inputNode = dynamic_cast<DoricInputNode *>(object); | ||||||
|  |  | ||||||
|  |   inputNode->onFocusChange(hasFocus); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -15,7 +15,7 @@ public: | |||||||
|   void onTextChange(QString pointer, QString text); |   void onTextChange(QString pointer, QString text); | ||||||
|  |  | ||||||
|   Q_INVOKABLE |   Q_INVOKABLE | ||||||
|   void onFocusChange(QString pointer); |   void onFocusChange(QString pointer, bool hasFocus); | ||||||
| signals: | signals: | ||||||
| }; | }; | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user