Skip to content

Commit

Permalink
allow item renderers to address sub properties
Browse files Browse the repository at this point in the history
  • Loading branch information
ianharrigan committed Mar 27, 2024
1 parent 0b57737 commit 8231e44
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions haxe/ui/core/ItemRenderer.hx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import haxe.ui.events.ItemRendererEvent;
import haxe.ui.events.MouseEvent;
import haxe.ui.events.UIEvent;
import haxe.ui.util.TypeConverter;
import haxe.ui.util.Variant;

class ItemRenderer extends Box {
@:clonable public var autoRegisterInteractiveEvents:Bool = true;
Expand Down Expand Up @@ -218,11 +219,25 @@ class ItemRenderer extends Box {
}

for (f in fieldList) {
var property:String = "value";
var v = Reflect.getProperty(valueObject, f);
var c:Component = findComponent(f, null, true);
var componentId = f;
var n = f.indexOf(".");
if (n != -1) {
componentId = f.substring(0, n);
property = f.substring(n + 1);
}
var c:Component = findComponent(componentId, null, true);
if (c != null && v != null) {
var propValue = TypeConverter.convertTo(v, TypeMap.getTypeInfo(c.className, "value"));
c.value = propValue;
var typeInfo = TypeMap.getTypeInfo(c.className, property);
var propValue = TypeConverter.convertTo(v, typeInfo);
if (property == "value") {
c.value = propValue;
} else if (typeInfo == "variant") {
Reflect.setProperty(c, property, Variant.fromDynamic(v));
} else {
Reflect.setProperty(c, property, v);
}

if (autoRegisterInteractiveEvents) {
if ((c is InteractiveComponent) || (c is ItemRenderer)) {
Expand Down

0 comments on commit 8231e44

Please sign in to comment.