Hi, when trying to hide properties in a PropertyGrid programmatically, it doesn’t work. Not only do the exposed apis (hide(), .visible, .hidden) do nothing, but also styling in the .xml (<property id=“intProp” hidden…) will not work.
@:build(haxe.ui.ComponentBuilder.build("assets/ui.xml"))
class TestBox extends Box {
public function new() {
super();
//tried with all of these
intProp.hide();
intProp.visible = false;
intProp.hidden = true;
}
}
I tried looking through the source code to try and diagnose myself but it isn’t clear what could be happening. I am also unable to remove the property with removeComponent().
So, ill have to double check, but i dont think that this is currently supported. That said, i think it is a perfectly reasonable (and valid) expectation. So Ill add it.
You’re right, it does seem to work when embedded into the .xml.
I’ve been trying to call Property.hide() in the PropertyGrid constructor so that the properties displayed would be dependent on some variables in memory. Also I tried pulling out the function which hide the properties and calling it after the constructor, still didn’t work. However, it did work after an async delay.
@:build(haxe.ui.ComponentBuilder.build("assets/prop_grid.xml"))
class MyPropertyGrid extends VBox {
public function new() {
super();
intProp.hide();
}
public function alter(): Void {
intProp.hide();
}
}
...
//doesn't hide
@:bind(display_grid_button, MouseEvent.CLICK)
private function displayGrid(e) {
var pg = new MyPropertyGrid();
Screen.instance.addComponent(pg);
}
...
//doesn't hide
@:bind(display_grid_button, MouseEvent.CLICK)
private function displayGrid(e) {
var pg = new MyPropertyGrid();
Screen.instance.addComponent(pg);
pg.alter();
}
...
//DOES hide
@:bind(display_grid_button, MouseEvent.CLICK)
private function displayGrid(e) {
var pg = new MyPropertyGrid();
Screen.instance.addComponent(pg);
sys.thread.Thread.create(() -> {
Sys.sleep(.5);
pg.alter();
});
}
So I’m guessing it’s just dependent on the internals of the UI lifecycle.
Right, so it might not be “ready” by that point, ill have a look tomorrow and see if i can clean that up.
FYI: you can also use Toolkit.callLater(() -> ...); which will call the function on the “next frame”, but ill take a look tomorrow and see if there is a way to not have to use either method.