I just have some small questions, just putting them in a thread here… hope thats ok?
1:
So, if you have some images in the local folder of a native build (this is Kha-native) … <image resource="mylocalfile.png" /> or say <button icon="files/icon.png" /> the local files wont be
loaded… but if you use <button icon="files:///c:\\mydir\\files\\icon.png" \> it seems to work. Now, this isnt very practical i guess, so how do you load local files at runtime? Is it possible?
2.
Second, i have question about <ListView> … If i’m creating a binding in code - say:
@:bind(fileList.dataSource)
public var ds : ArrayDataSource<Dynamic>;
Whenever i create a new ArrayDataSource on ds and add items to it i would expect the old items to go away, but instead the new ones are just being added to the list, making it longer.
Is it supposed to work that way? Should i clear the list in some way before adding items to it? …I cant find any clear or remove items function though…
3:
Adding a binding from code using @:bind works - but how would i do it if i wanted to the binding in the xml/markup ? … say something like this: <ListView dataSource="${ds} />
It doesnt seem to work that way…? Or am i missing something?
@:build(haxe.ui.macros.ComponentMacros.build("ui/mymarkup.xml"))
class Comp extends haxe.ui.containers.VBox
{
public var ds : ArrayDataSource<Dynamic>;
}
Sorry to bother you with all these questions, but sometimes its hard to find out the answers if im not able to find any good matching examples or documentation
Will answer fully a little later (snowed under in meetings at the moment)… in a nutshell though, 1 can be done with modules and ive never tried to use datasources with binding, so may need some tweaks there.
Just a comment to 2 : In the custom component - setting the dataSource by code works as expected. So there’s something odd about the binding then i guess…
How can this be handled without embedding the files?
Does the image component support loading of runtime images from a path or should i make my own wrapper for it?
[EDIT : Seems i misunderstood how this works - You add “file://” to indicate that its a local file, but doesnt have to be a hardcoded full path - relative files work too. ! " . Sorry about that fuzz
Right, gotcha… so yeah, you can load from embedded resources, files and http/s:
I think that covers most uses cases? If you have a suggestion for an addition, im all ears… Also, btw, recently (well, months now i guess) you can also set an image resource as an an haxe.ui.backend.ImageData - this is a typedef that lives inside each backend so varies from backend to back, for example, in haxeui-kha:
So this means you can construct a kha.Image in anyway you want (even draw it yourself in code) and set an Images .resource property.
Ill have a play with the bound data sources shortly