use new event delegate in HomeContext
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user