1. added border-hover-interaction

2. updated textarea-focus-interaction
This commit is contained in:
ronoaer 2023-09-26 16:38:08 +08:00
parent 8b08a5bee0
commit ee99565b63

View file

@ -9,71 +9,99 @@ Rectangle {
property alias textArea: textArea property alias textArea: textArea
property alias textAreaText: textArea.text property alias textAreaText: textArea.text
property string borderHoveredColor: "#494B50"
property string borderNormalColor: "#2C2D30"
property string borderFocusedColor: "#d7d8db"
height: 148 height: 148
color: "#1C1D21" color: "#1C1D21"
border.width: 1 border.width: 1
border.color: "#2C2D30" border.color: getBorderColor(borderNormalColor)
radius: 16 radius: 16
FlickableType { MouseArea {
id: fl id: parentMouse
interactive: false anchors.fill: parent
cursorShape: Qt.IBeamCursor
onClicked: textArea.forceActiveFocus()
hoverEnabled: true
anchors.top: parent.top FlickableType {
anchors.bottom: parent.bottom id: fl
contentHeight: textArea.implicitHeight interactive: false
TextArea {
id: textArea
width: parent.width anchors.top: parent.top
anchors.bottom: parent.bottom
contentHeight: textArea.implicitHeight
TextArea {
id: textArea
topPadding: 16 width: parent.width
leftPadding: 16
anchors.topMargin: 16
anchors.bottomMargin: 16
color: "#D7D8DB" topPadding: 16
selectionColor: "#633303" leftPadding: 16
selectedTextColor: "#D7D8DB" anchors.topMargin: 16
placeholderTextColor: "#878B91" anchors.bottomMargin: 16
font.pixelSize: 16 color: "#D7D8DB"
font.weight: Font.Medium selectionColor: "#633303"
font.family: "PT Root UI VF" selectedTextColor: "#D7D8DB"
placeholderTextColor: "#878B91"
placeholderText: root.placeholderText font.pixelSize: 16
text: root.text font.weight: Font.Medium
font.family: "PT Root UI VF"
onCursorVisibleChanged: { placeholderText: root.placeholderText
if (textArea.cursorVisible) { text: root.text
fl.interactive = true
} else { onCursorVisibleChanged: {
fl.interactive = false if (textArea.cursorVisible) {
fl.interactive = true
} else {
fl.interactive = false
}
}
wrapMode: Text.Wrap
MouseArea {
id: textAreaMouse
anchors.fill: parent
acceptedButtons: Qt.RightButton
hoverEnabled: true
onClicked: {
fl.interactive = true
contextMenu.open()
}
}
onFocusChanged: {
root.border.color = getBorderColor(borderNormalColor)
}
ContextMenuType {
id: contextMenu
textObj: textArea
} }
} }
}
wrapMode: Text.Wrap onPressed: {
root.border.color = getBorderColor(borderFocusedColor)
}
MouseArea { onExited: {
anchors.fill: parent root.border.color = getBorderColor(borderNormalColor)
acceptedButtons: Qt.RightButton }
onClicked: {
fl.interactive = true
contextMenu.open()
}
}
ContextMenuType { onEntered: {
id: contextMenu root.border.color = getBorderColor(borderHoveredColor)
textObj: textArea
}
} }
} }
//todo make whole background clickable, with code below we lose ability to select text by mouse
// MouseArea { function getBorderColor(noneFocusedColor) {
// anchors.fill: parent return textArea.focus ? root.borderFocusedColor : noneFocusedColor
// cursorShape: Qt.IBeamCursor }
// onClicked: textArea.forceActiveFocus()
// }
} }