diff --git a/Nasal/canvas/api.nas b/Nasal/canvas/api.nas index 02809ef9b..dab3069f8 100644 --- a/Nasal/canvas/api.nas +++ b/Nasal/canvas/api.nas @@ -39,14 +39,11 @@ Group._element_factories = { io.include(include_path~"canvas.nas"); # @param g Canvas ghost -var wrapCanvas = func(g) -{ - if( g != nil and g._impl == nil ) - g._impl = { - parents: [PropertyElement, Canvas], - _node: props.wrapNode(g._node_ghost) - }; - return g; +var wrapCanvas = func(g) { + if (g != nil and g._impl == nil) { + g._impl = Canvas._new(g); + } + return g; } # Create a new canvas. Pass parameters as hash, eg: diff --git a/Nasal/canvas/api/canvas.nas b/Nasal/canvas/api/canvas.nas index 98e5cf010..ea0db6304 100644 --- a/Nasal/canvas/api/canvas.nas +++ b/Nasal/canvas/api/canvas.nas @@ -5,6 +5,15 @@ # not to be confused with the namespace canvas (case sensitive!) # var Canvas = { + # private helper for wrapCanvas; + _new: func(canvas_ghost) { + var obj = { + parents: [Canvas, PropertyElement], + _node: props.wrapNode(canvas_ghost._node_ghost), + }; + return obj; + }, + # Place this canvas somewhere onto the object. Pass criterions for placement # as a hash, eg: #