From bdbd3848af022aefa088927aa5f7288589e15657 Mon Sep 17 00:00:00 2001 From: Henning Stahlke Date: Sat, 12 Jan 2019 23:03:39 +0100 Subject: [PATCH] comments, bugfixes and use API --- Nasal/canvas/MapStructure.nas | 4 ++-- Nasal/canvas/gui.nas | 17 +++++++++++++++-- Nasal/canvas/gui/styles/DefaultStyle.nas | 8 ++++---- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/Nasal/canvas/MapStructure.nas b/Nasal/canvas/MapStructure.nas index 48c42382f..c3a3a55b5 100644 --- a/Nasal/canvas/MapStructure.nas +++ b/Nasal/canvas/MapStructure.nas @@ -999,7 +999,7 @@ SymbolLayer.Controller = { addVisibilityListener: func() { var m = me; append(m.listeners, setlistener( - m.layer._node.getNode("visible"), + m.layer._node.getNode("visible",1), func m.layer.update(), #compile("m.layer.update()", ""), 0,0 @@ -1461,7 +1461,7 @@ OverlayLayer.Controller = { addVisibilityListener: func() { var m = me; append(m.listeners, setlistener( - m.layer._node.getNode("visible"), + m.layer._node.getNode("visible", 1), func m.layer.update(), #compile("m.layer.update()", ""), 0,0 diff --git a/Nasal/canvas/gui.nas b/Nasal/canvas/gui.nas index 93d60d5e8..e566aa874 100644 --- a/Nasal/canvas/gui.nas +++ b/Nasal/canvas/gui.nas @@ -1,3 +1,14 @@ +# +# FlightGear canvas gui +# Namespace: canvas +# +# Classes: +# WindowButton +# Window +# +# see also api.nas + + var gui = { widgets: {}, focused_window: nil, @@ -99,15 +110,17 @@ var Window = { { var placements = me._canvas._node.getChildren("placement"); # Do not remove canvas if other placements exist - if( size(placements) > 1 ) + if( size(placements) > 1 ) { foreach(var p; placements) { if( p.getValue("type") == "window" and p.getValue("id") == me.get("id") ) p.remove(); } - else + } + else { me._canvas.del(); + } me._canvas = nil; } if (me._node != nil) { diff --git a/Nasal/canvas/gui/styles/DefaultStyle.nas b/Nasal/canvas/gui/styles/DefaultStyle.nas index 4d3de27fa..e5421ea11 100644 --- a/Nasal/canvas/gui/styles/DefaultStyle.nas +++ b/Nasal/canvas/gui/styles/DefaultStyle.nas @@ -49,7 +49,7 @@ DefaultStyle.widgets.button = { }, setText: func(model, text) { - me._label.set("text", text); + me._label.setText(text); var min_width = math.max(80, me._label.maxWidth() + 16); model.setLayoutMinimumSize([min_width, 16]); @@ -130,7 +130,7 @@ DefaultStyle.widgets.checkbox = { }, setText: func(model, text) { - me._label.set("text", text); + me._label.setText(text); var min_width = me._label.maxWidth() + 24; model.setLayoutMinimumSize([min_width, 18]); @@ -203,7 +203,7 @@ DefaultStyle.widgets.label = { } me._createElement("text", "text") - .set("text", text); + .setText(text); var hfw_func = nil; var min_width = me._text.maxWidth() + 4; @@ -330,7 +330,7 @@ DefaultStyle.widgets["line-edit"] = { }, setText: func(model, text) { - me._text.set("text", text); + me._text.setText(text); model._onStateChange(); }, update: func(model)