Use MouseArea to catch click instead of onClicked

This is necessary because when you click it, the 'checked' property no longer depends on the active extruder. So prevent it from being clicked at all and handle the click separately in this MouseArea.

Contributes to issue CURA-5876.
This commit is contained in:
Ghostkeeper 2018-11-30 16:18:46 +01:00
parent ed37e692a3
commit 82d4897ba4
No known key found for this signature in database
GPG key ID: 86BEF881AE2CF276

View file

@ -136,9 +136,19 @@ Item
OldControls.CheckBox
{
checked: Cura.MachineManager.activeStack != null ? Cura.MachineManager.activeStack.isEnabled : false
onClicked: Cura.MachineManager.setExtruderEnabled(selectors.model.index, checked)
height: UM.Theme.getSize("setting_control").height
style: UM.Theme.styles.checkbox
/* Use a MouseArea to process the click on this checkbox.
This is necessary because actually clicking the checkbox
causes the "checked" property to be overwritten. After
it's been overwritten, the original link that made it
depend on the active extruder stack is broken. */
MouseArea
{
anchors.fill: parent
onClicked: Cura.MachineManager.setExtruderEnabled(Cura.ExtruderManager.activeExtruderIndex, !parent.checked)
}
}
}