Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Popup (context) menu in a Modal dialog

    SDK Help
    0
    6
    552
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H
      Helper
      last edited by

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

      User Information:
      Cinema 4D Version:    
      Platform:      
      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..

      1 Reply Last reply Reply Quote 0
      • H
        Helper
        last edited by

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

        Hi,

        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:
        http://c4dprogramming.wordpress.com/2012/11/25/treeview-made-simple-part-1/
        http://c4dprogramming.wordpress.com/2012/12/01/treeview-made-simple-part-2-folding-selections/

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

        1 Reply Last reply Reply Quote 0
        • H
          Helper
          last edited by

          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?

          1 Reply Last reply Reply Quote 0
          • H
            Helper
            last edited by

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

            One of the forum posts on the subject: https://developers.maxon.net/forum/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.

            AFAIK.
            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.

            -ScottA

            1 Reply Last reply Reply Quote 0
            • H
              Helper
              last edited by

              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!

              1 Reply Last reply Reply Quote 0
              • H
                Helper
                last edited by

                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)
                {
                    switch(id)
                	{
                		case MY_LISTVIEW:
                			HandleListviewClick();
                			break;
                	}
                	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(GetInputState(BFM_INPUT_MOUSE, BFM_INPUT_MOUSERIGHT, res))
                    {
                         if (res.GetLong(BFM_INPUT_VALUE) == 1)
                            DisplayPopupMenu();
                    }
                }
                  
                Bool MyDialog::DisplayPopupMenu()
                {
                	enum
                	{
                		M_EXPLORER = FIRST_POPUP_ID,
                		M_RENAME,
                		M_DELETE
                	};
                	
                	BaseContainer menuItems;
                	menuItems.SetString(M_EXPLORER, "Show in Explorer");
                	menuItems.SetString(M_RENAME, "Rename..");
                	menuItems.SetString(M_DELETE, "Delete");
                    	LONG popupResult = ShowPopupMenu(NULL, MOUSEPOS, MOUSEPOS, menuItems, 		POPUP_CENTERHORIZ || POPUP_CENTERVERT);
                    	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.

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post