fix(StatusRadioButtonRow): ensure checked state is propagated properly

There were cases in which this component was used and its `checked` state wasn't
properly emitted to the underlying component.

This commit fixes that by ensuring the `MouseArea` only alters the radio button's
`checked` state and let the radio button handle the event propagation.
This commit is contained in:
Pascal Precht 2021-03-19 11:21:02 +01:00 committed by Iuri Matias
parent accf92be2f
commit a27f9cf25d
1 changed files with 18 additions and 12 deletions

View File

@ -31,6 +31,17 @@ Rectangle {
anchors.leftMargin: Style.current.padding
}
MouseArea {
cursorShape: Qt.PointingHandCursor
anchors.fill: parent
hoverEnabled: true
onEntered: root.isHovered = true
onExited: root.isHovered = false
onClicked: {
radioButton.checked = true
}
}
StatusRadioButton {
id: radioButton
anchors.verticalCenter: parent.verticalCenter
@ -40,18 +51,13 @@ Rectangle {
rightPadding: 0
checked: root.checked
onCheckedChanged: root.radioCheckedChanged(checked)
}
MouseArea {
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
anchors.fill: parent
hoverEnabled: true
onPressed: mouse.accepted = false
onEntered: root.isHovered = true
onExited: root.isHovered = false
onClicked: {
if (!radioButton.checked) {
root.radioCheckedChanged(true)
}
}
}
}