Client Feature Right Click Menu

Client Feature Right Click Menu

Anonymous
Not applicable
943 Views
3 Replies
Message 1 of 4

Client Feature Right Click Menu

Anonymous
Not applicable

Does anyone out there know how to add to the right click menu of a client feature in the browser using the API? I'm trying to mimmick the right click menu that pops up when you right click other features like extrusion or hole in the browser. ie: "edit feature", "redefine",  etc.

0 Likes
Accepted solutions (1)
944 Views
3 Replies
Replies (3)
Message 2 of 4

cadull_rb
Advocate
Advocate

It took me a while to find it too, as the name wasn't what I was expecting. You need to handle events for Application.CommandManager.UserInputEvents.OnLinearMarkingMenu.

 

Regards,

cadull

0 Likes
Message 3 of 4

Anonymous
Not applicable

Okay that's a good start. Would you happen to have an example handle? I'm trying to use the "rack face" sample to figure out how events are handled.

 

Thanks again for the help so far.

-Thomas

0 Likes
Message 4 of 4

cadull_rb
Advocate
Advocate
Accepted solution

My event framework is a little complex, but the following should give you some ideas. I verify that just my client feature is selected before adding a button definition to the linear menu.

 

void OnLinearMarkingMenu(ObjectsEnumerator selectedEntities, SelectionDeviceEnum selectionDevice, CommandControls linearMenu, NameValueMap additionalInfo)
{
    AssemblyDocument assembly = Addin.Application.ActiveEditDocument as AssemblyDocument;
    if (assembly != null && selectedEntities.Count == 1 && new NotchDefinitionFeature(assembly, selectedEntities[1]).Exists)
        linearMenu.AddButton(m_editButton.ButtonDefinition, false, true, "AssemblyShowAssemblyFeatureDimsCtxCmd", false);
}

 

 Then my button execute handler, which is also used for the button on the ribbon panel to create a new client feature, displays a dialog to edit the client feature. My event framework inserts the first parameter which could be avoided if we used a different handler for each button.

 

void OnExecute(ButtonDefinition events, NameValueMap context)
{
    AssemblyDocument assembly = Addin.Application.ActiveEditDocument as AssemblyDocument;
    if(assembly==null)
        throw new Exception(events.DisplayName + " requires an active assembly document.");

    object selected = (events.InternalName==m_editButton.InternalName && assembly.SelectSet.Count==1) ? assembly.SelectSet[1] : null;
    NotchDefinitionFeature clientFeature = new NotchDefinitionFeature(assembly, selected);
    new NotchDefinitionDialog(clientFeature);
}

 

Regards,

cadull

0 Likes