I need to be able to define where a specific menu was called. Here is the basic interface:

menu for actions

Each line has a triangle at the end. When I click the triangle, a menu pops up, which will include a few operators that will change the action relevant to that row. The problem is, I can't figure out how to pass parameters into the menu to tell the menu "this is the action you're changing." I'm probably misunderstanding something about properties. Here's some relevant code.

class ShotsActionChange(bpy.types.Menu):
    bl_idname = "SHOTS_MT_alter_action"
    bl_label = "Alter action"

    action_id = bpy.props.IntProperty(default=0)

    def draw(self, context):
        layout = self.layout
        layout.label(text="This is a test!")

# ....

# row-generator loop for the panel's draw method, where this menu is called:
    def action_row(self, layout, action, object=None):
        iconi = self.get_data_icon(object)
        obj_text = ""

        if object is not None:
            obj_text = object + " :: "

        row = layout.row()
        row.label(icon=iconi, text="")
        row.label(text=obj_text + action)
        row.menu("SHOTS_MT_alter_action", text="", icon="DOWNARROW_HLT")

What I want is for that last line to do something along the lines of:

row.menu("SHOTS_MT_alter_action", text="", icon="DOWNARROW_HLT").action_id = action

And that way, I can pass something into the menu. It spouts errors right now, but I don't think I know enough about the API to know whether this is impossible or just needs to be reworked. The menu itself is a hub for multiple operators, but do I need an operator that controls the opening of the menu? Any help is much appreciated.



Browse other questions tagged .