is it possible to add custom actions to a node using the data field?

10 views
Skip to first unread message

Siddharth Vaghela

unread,
Aug 6, 2012, 2:19:36 AM8/6/12
to sce...@googlegroups.com
Hi,
I am interested in adding the actions to be taken by the node (customized handling of updates) by using the data field in the node like this:

nodes: [
    {
          id: "node_id",
          type: "node",
          data: {
               action: function() {

               }

    }

]

is this possible?

regards,
Siddharth

Lindsay Kay

unread,
Aug 6, 2012, 4:22:22 AM8/6/12
to sce...@googlegroups.com

Hi, nope. The 'data' attribute is just for data, strictly JSON.

Could you expand on your use though? Might be something we should have in the API..

Siddharth Vaghela

unread,
Aug 6, 2012, 4:51:32 AM8/6/12
to sce...@googlegroups.com
i am developing widgets such as dials for my application. now these dials can be of different type - analog needle type, digital levels type, etc. the functionality to handle the update values needs to be stored with the widgets within the scenegraph so that the viewer application does not need to know the logic behind these update functions. it should be able to retrieve the widget node from the scenegraph, get the update callback function from the data section and execute it.

i hope i have been able to give a clear idea of what i am trying to do.

regards!
Siddharth


On Monday, 6 August 2012 13:52:22 UTC+5:30, Lindsay Kay wrote:

Hi, nope. The 'data' attribute is just for data, strictly JSON.

Could you expand on your use though? Might be something we should have in the API..

Hi,

Siddharth Vaghela

unread,
Aug 6, 2012, 4:57:45 AM8/6/12
to sce...@googlegroups.com
I know one very unsafe way of doing this would be to add the script as a string and then call the eval function. but i want to avoid doing that as far as possible.
Reply all
Reply to author
Forward
0 new messages