From 5f54a68491703cf53378b3a78d5880fba561073f Mon Sep 17 00:00:00 2001 From: Thomas Geymayer Date: Wed, 23 Oct 2013 17:33:12 +0200 Subject: [PATCH] Canvas: add helper to get parent of canvas.Element --- Nasal/canvas/api.nas | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Nasal/canvas/api.nas b/Nasal/canvas/api.nas index a08514635..4eb3d110d 100644 --- a/Nasal/canvas/api.nas +++ b/Nasal/canvas/api.nas @@ -142,6 +142,20 @@ var Element = { _node: props.wrapNode(ghost._node_ghost) }; }, + # Get parent group/element + getParent: func() + { + var parent_ghost = me._getParent(); + if( parent_ghost == nil ) + return nil; + + var type = props.wrapNode(parent_ghost._node_ghost).getName(); + var factory = me._getFactory(type); + if( factory == nil ) + return parent_ghost; + + return factory(parent_ghost); + }, # Check if elements represent same instance # # @param el Other Element or element ghost