onSelectionChanged UI event

This commit is contained in:
2021-09-27 23:20:05 -06:00
parent 4db843897a
commit bba93a711b
5 changed files with 38 additions and 19 deletions

View File

@@ -22,12 +22,10 @@
(enableMouseDrag)
}))
// TODO add onEntrySelected(), onEntryDeselected() callback to ArchiveUI and use these to change color if SelectByName or SelectByTags are used on an Entry that has a sprite in the entryspritesystem's dictionary
(set mousePressedCallback
->[self _x _y]
{
(controller.ToggleEntrySelection e)
(updateColor)
})
(set mouseStopDragCallback
->[self _dx _dy]
@@ -35,7 +33,7 @@
(dictSet positions positionKey (object x (cast this.x Float) y (cast this.y Float) z 0.0)))))
(method updateColor []
(if !(= -1 (controller.selectedEntries.indexOf e))
(if (controller.isSelected e)
{
(set color FlxColor.BLUE)
}

View File

@@ -208,3 +208,8 @@
(let [text (new FlxText 0 0 0 (error.replace "\n" "|"))]
(text.setFormat null 8 FlxColor.RED)
(showUI text)))
(method :Void onSelectionChanged [:Array<Entry> selectedEntries :Array<Entry> lastSelectedEntries]
(doFor e (selectedEntries.concat lastSelectedEntries)
(whenLet [sprite (dictGet spriteSystem.sprites e.id)]
(sprite.updateColor))))