Suggestion: Pass button name to event handler
Apologies if this is something already explained in the docs but I can't seem to find a way to make it work.
It would be great if the on_event
callback for Button
types could recieve the name of the clicked button in the ctx
table, in the same style as minetest recieves fields.
might be as simple as changing https://gitlab.com/luk3yx/minetest-flow/-/blob/main/init.lua?ref_type=heads#L1180
if btn_callbacks[field] then
ctx.form[field] = field
redraw_fs = btn_callbacks[field](player, ctx) or redraw_fs
-- Only run a single button callback
break
end
or maybe ctx.__btn_clicked = field
or somesuch so that it's treated somewhat special.
or even allow a value
field for Button
types and pass that around.
It would be useful if you have a large number of buttons which all have the exact same event handler code with only the value of the button changing.
Thanks.
Edited by Ketwaroo D. Yaasir