use new event delegate in HomeContext

This commit is contained in:
2023-01-30 16:44:52 +01:00
parent 8f7739c26a
commit 8934d40c0b
2 changed files with 30 additions and 13 deletions

View File

@@ -1,7 +1,11 @@
package lib.ui.rendere;
class List {
public function new() {}
class List implements UIEventDelegate{
private final onElementClick: Null<Int->Void>;
public function new(?onElementClick: Int->Void) {
this.onElementClick = onElementClick;
}
public function render(list:Array<String>): Canvas {
var canvas = new Canvas();
@@ -17,4 +21,18 @@ class List {
}
return canvas;
}
public function getEventHandlers(): UIEvents{
return {
onClick: handleClick
};
}
private function handleClick(e: {button:kernel.ButtonType, pos:Pos}): Void{
if (this.onElementClick == null){
return;
}
this.onElementClick(e.pos.y);
}
}