Some small questions

I just have some small questions, just putting them in a thread here… hope thats ok? :slight_smile:

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? :slight_smile:

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? :slight_smile:

@: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 :slight_smile:

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.

1 Like

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…

1 Like

repro test would nice, but if not ill try and work how you are using it… sounds like the binding is just being weird with data sources

sure!.. will make a test case :slight_smile:

1 Like

Great, thanks! Will be a big help

Ian

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? :slight_smile:

[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 :slight_smile:

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 :slight_smile:

Cheers,
Ian

2 Likes

Right, sorry for the huge delay, will be looking at this again sometime this weekend - been on holiday

Cheers,
Ian

No stress! Ive been quite busy, but im going to upload some tests that shows some odd binding issues :slight_smile: