-
-
Notifications
You must be signed in to change notification settings - Fork 82
Description
In a project I'm trying to implement HashLink support there are list dropdowns which are dynamically generated based on a schema, and one of the schemas contains a map that looks like ['A' => 0, 'B' => 1], which gets turned into something like { text: 'A', value: 0 } in the dataSource.
The project tries to update the dropdown by setting the selected item, but it does so using the value, which works on the C++ target but not on hashlink.
The issue is that setting selectedItem will convert the value passed to it to a string if it's not a anonymous structure.
haxeui-core/haxe/ui/components/DropDown.hx
Lines 493 to 511 in 578d61b
| private override function set_selectedItem(value:Dynamic):Dynamic { | |
| if (value == null) { | |
| return value; | |
| } | |
| var text = null; | |
| if (Type.typeof(value) == TObject) { | |
| text = value.text; | |
| if (text == null) { | |
| text = value.value; | |
| } | |
| } else { | |
| text = Std.string(value); | |
| } | |
| var index:Int = indexOfItem(text); | |
| selectedIndex = index; | |
| return value; | |
| } |
But indexOfItem compares the value with the one in dataSource disregarding the different type it now has (it was an int but now is a string, but value in dataSource is still an int). And in HXCPP for some reason having a:Dynamic = 2, b:String = "2", a == b will return true, but not on HL.
haxeui-core/haxe/ui/components/DropDown.hx
Lines 457 to 458 in 578d61b
| var item:Dynamic = _dropdown.dataSource.get(i); | |
| if (item == text || item.value == text || item.text == text) { |