Skip to content

Scripting: Assigned map.selectedLayers displays incorrectly #3451

Open
@eishiya

Description

@eishiya

When assigning to TileMap.selectedLayers, if the assigned array has its layers in any order other than ascending by layer ID and doesn't contain every layer in the map, the layers will be selected, but the Layers panel will only highlight the bottom-most layer. I confirmed that the layers were selected via Highlight Current Layer, and via tiled.activeAsset.selectedLayers.

Here for example, I selected all "Invalid" layers via script, in order from bottom to top (the same order they appear in map.layers). The layers are sorted by their ID (which I've added to their layer name, for convenience), so everything is highlighted correctly:
image
But here, I've switched layers 2 and 3, so they're no longer in ascending order, and thus only the bottom-most selected layer is highlighted (but all three layers are actually selected):
image

Sorting the layers prior to assigning to map.selectedLayers works to correctly highlight all layers regardless of order:

invalidLayers.sort(function(a,b) {return a.id - b.id;});
map.selectedLayers = invalidLayers;

Selecting every layer in the map also highlights the layers correctly, regardless of their order in the array.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugBroken behavior.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions