Also you could skip the explicit proc literal and use a method pointer instead: ->(w : Widget) { upd_lighttable(w) }) could be written as ->upd_lighttable(Widget).
And, as mentioned in the previous comment, you could turn the proc argument into a block parameter. This would allow calling the method with a block (which you don’t need to use here with the method pointers, but it’s still neat to have for other cases).
Simply add a & before @handler in the def parameters and before ->:
class LabelWidget < Widget
def initialize(@text : String, @x : Int32, @y : Int32, &@handler : Proc(Widget, Nil))
end
end
# ...
class MyAppUI < UI
def assemble()
@widgets.push(LabelWidget.new(" L ", 5, 5, &->upd_lighttable(Widget))
@widgets.push(LabelWidget.new(" P ", 5, 50, &->upd_play_from_previous(Widget))
end
end