diff --git a/doric-Qt/example/doric/resources/input.qml b/doric-Qt/example/doric/resources/input.qml index fa97e502..4d4ee148 100644 --- a/doric-Qt/example/doric/resources/input.qml +++ b/doric-Qt/example/doric/resources/input.qml @@ -4,7 +4,7 @@ import QtQuick.Controls 2.5 import "util.mjs" as Util import "gravity.mjs" as Gravity -TextArea { +TextField { property var wrapper property var uuid: Util.uuidv4() @@ -47,19 +47,11 @@ TextArea { onWidthChanged: { bg.implicitWidth = width console.log(tag, uuid + " onWidthChanged: " + this.width) - - let tempText = this.text - this.text = "" - this.text = tempText } onHeightChanged: { bg.implicitHeight = height console.log(tag, uuid + " onHeightChanged: " + this.height) - - let tempText = this.text - this.text = "" - this.text = tempText } onTextChanged: { @@ -72,6 +64,31 @@ TextArea { inputBridge.onFocusChange(wrapper, this.focus) } + onMaximumLengthChanged: { + console.log(tag, uuid + " onMaximumLengthChanged: " + this.maximumLength) + } + + property var inputType: 0 + + property var numberValidator: IntValidator {} + property var decimalValidator: DoubleValidator {} + property var alphabetValidator: RegExpValidator { regExp: /^[A-Z]+$/i} + + onInputTypeChanged: { + console.log(tag, uuid + " onInputTypeChanged: " + this.inputType) + switch (inputType) { + case 1: + this.validator = numberValidator + break + case 2: + this.validator = decimalValidator + break + case 3: + this.validator = alphabetValidator + break + } + } + 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 a2c45a9b..342cf091 100644 --- a/doric-Qt/example/doric/shader/DoricInputNode.cpp +++ b/doric-Qt/example/doric/shader/DoricInputNode.cpp @@ -42,6 +42,10 @@ void DoricInputNode::blend(QQuickItem *view, QString name, QJsonValue prop) { view->setProperty("rightPadding", prop["right"].toDouble()); view->setProperty("topPadding", prop["top"].toDouble()); view->setProperty("bottomPadding", prop["bottom"].toDouble()); + } else if (name == "maxLength") { + view->setProperty("maximumLength", prop.toInt()); + } else if (name == "inputType") { + view->setProperty("inputType", prop.toInt()); } else { DoricViewNode::blend(view, name, prop); }