Socket default_value change event

I’m writing a little node based addon, pretty much based on the ‘custom nodes template’ in the blender text editor, works well, but i’m struggling responding to certain events in the node editor.

There’s a couple of things that can change.

  1. Adding/Removing of nodes or node-links, when this happens, the nodetree’s update method is called, no problem here.

  2. any custom properties in draw_buttons, you can set a callback in the property definition to get called when it changes, also no problem here.

  3. Unlinked node sockets, when a socket is unlinked it shows a widget where the user gets to edit the default_value. Great! love it! But there is seemingly no way to get any notification when this happens

Repro case:

  1. Run the custom_nodes template in the text editor.
  2. Try to convince it to notify you when then “World” socket changes on MyCustomNode
1 Like

I think you’re right, there is no event for that (yet?).
Usually, I just create my own socket classes and use the socket types Blender provides. That gives much more flexibility.

Oh yeah custom sockets would indeed work! thanks for the tip!

I’m having problems getting an update event from a linked input socket

Like “Val” in this part of the image
image

Even if I use a Custom socket type with an update callback:

# Custom socket type
class MyCustomSocket(NodeSocket):
    bl_idname = 'CustomSocketType'
    bl_label = "Custom Node Socket"

    default_value: bpy.props.FloatProperty(default=0.987, update=on_custom_sock_update)

It doesn’t seems to be called when the “Value” output socket on the upstream node changes it’s default_value.

Am I missing something? Or is there another way of doing it?