added ui events to LayerdRootElement
This commit is contained in:
@@ -2,25 +2,31 @@ package lib.ui.elements;
|
||||
|
||||
import lib.ui.rendere.UIEventDelegate;
|
||||
|
||||
abstract EventMap(List<{bound:Rect, delegate:UIEventDelegate}>) {
|
||||
inline public function new(?i:List<{bound:Rect, delegate:UIEventDelegate}>) {
|
||||
/**
|
||||
Find the responsable UIElement to handle the event based on position. Element can be layerd.
|
||||
Elements added first are lower in the layer.
|
||||
**/
|
||||
abstract EventMap(Array<{bound:Rect, delegate:UIEventDelegate}>) {
|
||||
inline public function new(?i:Array<{bound:Rect, delegate:UIEventDelegate}>) {
|
||||
if (i == null) {
|
||||
this = new List<{bound:Rect, delegate:UIEventDelegate}>();
|
||||
this = new Array<{bound:Rect, delegate:UIEventDelegate}>();
|
||||
} else {
|
||||
this = i;
|
||||
}
|
||||
}
|
||||
|
||||
public function findResponseableDelegate(pos:Pos):UIEventDelegate {
|
||||
for (i in this) {
|
||||
if (i.bound.isInside(pos)) {
|
||||
return i.delegate;
|
||||
for (i in 0...this.length) {
|
||||
var newi = (this.length - 1) - i;
|
||||
var element = this[newi];
|
||||
if (element.bound.isInside(pos)) {
|
||||
return element.delegate;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function addElement(element:UIEventDelegate, bound:Rect) {
|
||||
this.add({bound: bound, delegate: element});
|
||||
public inline function addElement(element:UIEventDelegate, bound:Rect) {
|
||||
this.push({bound: bound, delegate: element});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user