Pārlūkot izejas kodu

added onItemOver

ncannasse 11 gadi atpakaļ
vecāks
revīzija
54c6c47aee
2 mainītis faili ar 11 papildinājumiem un 0 dzēšanām
  1. 7 0
      h2d/comp/ItemList.hx
  2. 4 0
      h2d/comp/Select.hx

+ 7 - 0
h2d/comp/ItemList.hx

@@ -48,8 +48,10 @@ class ItemList extends Box {
 					if( cursor != null ) cursor.remove();
 					cursor = new h2d.Bitmap(h2d.Tile.fromColor(style.selectionColor, Std.int(int.width), Std.int(int.height)), int);
 					int.onOver = function(_) {
+						onItemOver(i);
 					};
 					int.onOut = function(_) {
+						onItemOver(-1);
 					}
 					int.onPush = function(_) {
 					}
@@ -57,10 +59,12 @@ class ItemList extends Box {
 					int.onOver = function(_) {
 						if( cursor != null ) cursor.remove();
 						cursor = new h2d.Bitmap(h2d.Tile.fromColor(style.cursorColor, Std.int(int.width), Std.int(int.height)), int);
+						onItemOver(i);
 					};
 					int.onOut = function(_) {
 						if( cursor != null ) cursor.remove();
 						cursor = null;
+						onItemOver(-1);
 					}
 					int.onPush = function(_) {
 						if( this.selected != i ) {
@@ -78,6 +82,9 @@ class ItemList extends Box {
 			}
 		}
 	}
+
+	public dynamic function onItemOver( current : Int ) {
+	}
 	
 	public dynamic function onChange( selected : Int ) {
 	}

+ 4 - 0
h2d/comp/Select.hx

@@ -30,6 +30,7 @@ class Select extends Interactive {
 		while( p.parentComponent != null )
 			p = p.parentComponent;
 		list = new ItemList();
+		list.onItemOver = function(i) onItemOver(i < 0 ? null : options[i].value);
 		p.addChild(list);
 		list.addClass("popup");
 		list.evalStyle();
@@ -120,6 +121,9 @@ class Select extends Interactive {
 		if( selectedIndex == options.length - 1 )
 			selectedIndex = selectedIndex; // update value
 	}
+	
+	public dynamic function onItemOver( value : String ) {
+	}
 
 	override function resize( ctx : Context ) {
 		if( ctx.measure ) {