# pyNode with button: any way to find which node the button pressed was on?

I want to have a pyNode with some buttons on it that modify the node. Similar to how some of the built-in nodes work (Color Ramp, Curves, etc).

I can easily put a button on the node using an operator, but the operator doesn't seem to have any way of knowing which node actually called it? Clicking a button on a node doesn't select or make active that node and all I seem to have to work with is context and event?

So, is this possible using pyNodes? Is there a way to make a button without creating an operator? I couldn't see how that would be done either.

It's possible, but you need to set a property or two on your operator so that it can find the value. Eg:

class MyOperator(bpy.types.Operator):
tree: bpy.props.StringProperty()
node: bpy.props.StringProperty()
...


Then where ever you draw it, set those properties. Eg:

def draw_buttons(self, context, layout):
op = layout.operator("myoperator.operator")
op.tree = self.id_data.name
op.node = self.name
...


You can then use those values in the operator to find out where it was called from.