From 3f9dc54c85467c4188153ce2f84ef5cf1f5d16cd Mon Sep 17 00:00:00 2001 From: Roman Ludwicki Date: Wed, 25 Oct 2023 17:09:46 +0200 Subject: [PATCH] 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). --- .../canvas/gui/dialogs/PropertyTreeBrowser.nas | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/Nasal/canvas/gui/dialogs/PropertyTreeBrowser.nas b/Nasal/canvas/gui/dialogs/PropertyTreeBrowser.nas index b9d204b52..f017d5686 100644 --- a/Nasal/canvas/gui/dialogs/PropertyTreeBrowser.nas +++ b/Nasal/canvas/gui/dialogs/PropertyTreeBrowser.nas @@ -8,14 +8,14 @@ var PropertyTreeBrowser = { }; 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.simulatedTime = 0; m.singleShot = 1; m.window = canvas.Window.new([400, 550], "dialog") - .setTitle((node != nil ? node.getPath() : "/") ~ " - Property browser") + .setTitle(m.getWindowTitle(node)) .set("resize", 1); m.window.onClose = func m.onClose(); m.root = m.window.getCanvas(1) @@ -31,7 +31,7 @@ var PropertyTreeBrowser = { } m.propertyTree._view._root.addEventListener("click", func { 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(); if (!size(selected)) { return; @@ -53,7 +53,7 @@ var PropertyTreeBrowser = { } m.valueEntry.setText(value); } else { - m.window.setTitle(m.propertyTree.getNode().getPath() ~ " - Property browser"); + m.window.setTitle(m.getWindowTitle(m.propertyTree.getNode())); m.valueEntry.clear(); } }); @@ -131,4 +131,13 @@ var PropertyTreeBrowser = { me.propertyTree.del(); me.window.del(); }, + + getWindowTitle: func(node) { + var path = (node == nil ? "/" : node.getPath()); + if (path == "" or path == nil) { + path = "/"; + } + + return path ~ " - Property browser"; + }, };