1
0
Fork 0

For PropertyTreeBrowser, set the path in the title as "/" when the node returns an empty string

Set the title in one place (in a separate function).
This commit is contained in:
Roman Ludwicki 2023-10-25 17:09:46 +02:00
parent 0cd24b172e
commit 3f9dc54c85

View file

@ -8,14 +8,14 @@ var PropertyTreeBrowser = {
}; };
m.resetTitleTimer = maketimer(5, func { m.resetTitleTimer = maketimer(5, func {
m.window.setTitle(m.propertyTree.getNode().getPath() ~ " - Property browser"); m.window.setTitle(m.getWindowTitle(m.propertyTree.getNode()));
m.resetTitleTimer.stop(); m.resetTitleTimer.stop();
}); });
m.simulatedTime = 0; m.simulatedTime = 0;
m.singleShot = 1; m.singleShot = 1;
m.window = canvas.Window.new([400, 550], "dialog") m.window = canvas.Window.new([400, 550], "dialog")
.setTitle((node != nil ? node.getPath() : "/") ~ " - Property browser") .setTitle(m.getWindowTitle(node))
.set("resize", 1); .set("resize", 1);
m.window.onClose = func m.onClose(); m.window.onClose = func m.onClose();
m.root = m.window.getCanvas(1) m.root = m.window.getCanvas(1)
@ -31,7 +31,7 @@ var PropertyTreeBrowser = {
} }
m.propertyTree._view._root.addEventListener("click", func { m.propertyTree._view._root.addEventListener("click", func {
props.globals.setValue("/sim/gui/dialogs/property-browser/selected", m.propertyTree.getNode().getPath()); props.globals.setValue("/sim/gui/dialogs/property-browser/selected", m.propertyTree.getNode().getPath());
m.window.setTitle(m.propertyTree.getNode().getPath() ~ " - Property browser"); m.window.setTitle(m.getWindowTitle(m.propertyTree.getNode()));
var selected = m.propertyTree.getSelectedItems(); var selected = m.propertyTree.getSelectedItems();
if (!size(selected)) { if (!size(selected)) {
return; return;
@ -53,7 +53,7 @@ var PropertyTreeBrowser = {
} }
m.valueEntry.setText(value); m.valueEntry.setText(value);
} else { } else {
m.window.setTitle(m.propertyTree.getNode().getPath() ~ " - Property browser"); m.window.setTitle(m.getWindowTitle(m.propertyTree.getNode()));
m.valueEntry.clear(); m.valueEntry.clear();
} }
}); });
@ -131,4 +131,13 @@ var PropertyTreeBrowser = {
me.propertyTree.del(); me.propertyTree.del();
me.window.del(); me.window.del();
}, },
getWindowTitle: func(node) {
var path = (node == nil ? "/" : node.getPath());
if (path == "" or path == nil) {
path = "/";
}
return path ~ " - Property browser";
},
}; };