cschreib / lxgui

Portable, real time, modular and data-driven GUI C++ library.
https://cschreib.github.io/lxgui
MIT License
75 stars 20 forks source link

Script handler inheritance #76

Closed cschreib closed 3 years ago

cschreib commented 3 years ago

Previously, inherited script handles would be completely replaced if re-defined in the child frames, because there could only ever be one callback function/script registered to a particular event. This PR changes this so that more than one callback can be registered. This enables child frames to add callbacks to be executed after the callbacks registered by their inherited parents.

The old behavior of replacing callbacks can be recovered by specifying override="true" in the XML script, e.g., <OnUpdate override="true"> ... </OnUpdate>. In C++ and Lua, add_script() uses the new behavior, and set_script() preserves the old behavior.

As a side effect, it also fixes the following problems: