By setting the controller
attribute on an XML frame, the engine will run the associated Lua script automatically when the UI frame is created and deliver events (such as OnEnable/OnDisable) to the Lua script. This makes it easier to customize UI frames in Lua and allows you to create reusable UI components with a combination of XML and Lua. Such Lua scripts also work in the UI previewer so you can iterate on UI related Lua code (like UI animations) much faster without the need to start the entire game.
OnEnable
Sent when the frame becomes active (visible)OnDisable
Sent when the frame becomes inactive (hidden)OnPreview
Sent automatically when viewed in the UI previewer. Note that OnPreview is only sent to the root layout and not any includes.script_file_name
https://platform.wildsky.dev/arcade/game/606 (Click “Source” to download)