Ensure that menu items for extruder are added to right spot in context menu

Fixes CURA-10649
This commit is contained in:
Jaime van Kessel 2023-06-02 13:51:43 +02:00
parent bba1362bad
commit d8a88739a6
No known key found for this signature in database
GPG Key ID: C85F7A3AF1BAA7C4

View File

@ -44,8 +44,19 @@ Cura.Menu
onTriggered: CuraActions.setExtruderForSelection(model.id)
shortcut: "Ctrl+" + (model.index + 1)
}
// Add it to the fifth position (and above) as we want it to be added after the extruder header.
onObjectAdded: function(index, object) { base.insertItem(index + 5, object) }
onObjectAdded: function(index, object) {
var extruder_header_location = 5;
// Find the location of the extruder header and insert it below that.
for (var i = 0; i < base.count; i++)
{
if(base.itemAt(i) === extruderHeader)
{
extruder_header_location = i + 1;
}
}
base.insertItem(extruder_header_location + index, object)
}
onObjectRemoved: function(index, object) { base.removeItem(object) }
}