[Bf-taskforce25] preferred method for popups calling operators

Campbell Barton ideasman42 at gmail.com
Sun Feb 1 06:35:39 CET 2009


Would using uiPupMenuBegin witin an operators invoke function be the
prefered way have popup menus call other operators?
such as Specials menu, Add sequence strip.
Basically any popup menu that isnt calling a single operator with an
enum "type" property.

If so then there are a number of these that can be changed over.

BTW, I copied this from the image toolbox, the way OPERATOR_CANCELLED
is used here I find a bit confusing.

/* edit face toolbox */
static int editmesh_face_toolbox_invoke(bContext *C, wmOperator *op,
wmEvent *event)
{
	uiMenuItem *head;

	head= uiPupMenuBegin("Edit Faces");

	uiMenuItemO(head, "MESH_OT_fill_mesh", ICON_BLANK1);
	uiMenuItemO(head, "MESH_OT_beauty_fill", ICON_BLANK1);
	uiMenuItemO(head, "MESH_OT_convert_quads_to_tris", ICON_BLANK1);
	uiMenuItemO(head, "MESH_OT_convert_tris_to_quads", ICON_BLANK1);
	uiMenuItemO(head, "MESH_OT_edge_flip", ICON_BLANK1);
	uiMenuItemO(head, "MESH_OT_faces_shade_smooth", ICON_BLANK1);
	uiMenuItemO(head, "MESH_OT_faces_shade_solid", ICON_BLANK1);
	uiPupMenuEnd(C, head);

	return OPERATOR_CANCELLED;
}

void VIEW3D_OT_editmesh_face_toolbox(wmOperatorType *ot)
{
	/* identifiers */
	ot->name= "Edit Faces";
	ot->idname= "VIEW3D_OT_editmesh_face_toolbox";

	/* api callbacks */
	ot->invoke= editmesh_face_toolbox_invoke;
	ot->poll= ED_operator_editmesh;
}


- Campbell


More information about the Bf-taskforce25 mailing list