Popup (context) menu in a Modal dialog

On 08/08/2013 at 09:26, xxxxxxxx wrote:

User Information:
Cinema 4D Version:    
Language(s) :

I have made this:

But what I really want is this, from the C-Motion

So there are two issues:

  1. I made my dialog (the upper) using a SimpleListView. And it works, I found the TreeView too complicated and time consuming, I found no source code examples.
  2. What I need is a popup menu (context menu) like above.

All of this would have been max 10 minutes of work in C#. I have now used a couple of hours, banging my head against the wall. I have no idea how to trap a right mouse click, and how to create and display a popup menu.

Any links to any documentation on this is most welcome. And yes, I have the SDK and have tried to find out about it, but there is a limit on how much time I can spend in this.. I just do not have the head for C++ combined with C4D it seems..

On 08/08/2013 at 09:52, xxxxxxxx wrote:


You can find an example of use of the TreeViewCustomGui in the _  Active Object_ example ( cinema4dsdk/source/gui/activeobject.cpp ). If this example is too complex you can refer to this tutorial in the C4D programming blog:

And if you search for "popup menu" or "popupmenu" in the SDK documentation you'll quickly find ShowPopupMenu() method in the c4d_gui functions.

On 08/08/2013 at 10:14, xxxxxxxx wrote:

Thanks for the links! I will have a look at them, if I want to switch from Listview to Treeview.

Originally posted by xxxxxxxx

And if you search for "popup menu" or "popupmenu" in the SDK documentation you'll quickly find ShowPopupMenu() method in the c4d_gui functions.

Yes, I found those, almost immediately.
My challenge / problem when writing plugins is not that I do not find topics like this. The problem is:
How on earth do I make a pop up menu pop up, when I right-click something, in this case an item in my listview?

On 08/08/2013 at 12:04, xxxxxxxx wrote:

One of the forum posts on the subject: https://plugincafe.maxon.net/topic/6421/6891_live-feedback-from-a-multilineedittext-gui&KW=ShowPopupMenu&PID=28731#28731

I've never use a pop-up in combination with a listView gizmo. So I don't know if there's any issues with that or not. But I have used a pop-up in my Auto Complete plugin.
You can download the plugin and the source code for it here:https://sites.google.com/site/scottayersmedia/plugins

It uses the period keyboard key to open the pop-up list. So you'll have to change that code to open it using your MB instead.

Nobody else has posted any working & compiled pop-up code examples that you can learn from like this. I don't think there's an example in the SDK (I can't remember).
So my Auto Complete plugin might be your best place to start.
Most of the plugins I post there are only there because the code examples don't exist anyplace else.


On 08/08/2013 at 13:03, xxxxxxxx wrote:

Hi Scott, much appreciated!
I will look at it, and see what I can get out of it!

On 08/08/2013 at 15:06, xxxxxxxx wrote:

Hi again Scott, I owe you a BIG thank you for this!
As always, when you know how to do it, it is simple.
The clue, or the problem for me, was to detect the mouse action.
Here is the code, somewhat simplified:

Bool MyDialog::Command(LONG id, const BaseContainer &msg)
	return TRUE;
Bool MyDialog::HandleListviewClick()
 _    // This is where I was stuck,  **GetInputState** is what I needed, the rest is peanuts  _
 _    // I was looking for mouse events, when the solution was to get the mouse state_
         if (res.GetLong(BFM_INPUT_VALUE) == 1)
Bool MyDialog::DisplayPopupMenu()
	BaseContainer menuItems;
	menuItems.SetString(M_EXPLORER, "Show in Explorer");
	menuItems.SetString(M_RENAME, "Rename..");
	menuItems.SetString(M_DELETE, "Delete");
    	GePrint("popupResult " + LongToString(popupResult));

This is all!!!
And I buried my head in docs and everything.. for hours.. Ok, have learnt this. Hope others will benefit from this, and thank you again Scott.