Undocking custom plugin menu



  • On 03/05/2017 at 12:06, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   R18 
    Platform:   Windows  ;   Mac OSX  ; 
    Language(s) :     C++  ;

    ---------
    Hi,

    Something being reported by one of my customers, for which I don't find an explanation.
    I have this "proxy" CommandData plugin, which its sole purpose is to provide custom menu entries in the plugin menu. The plugin has no icon, and an empty string as plugin name.
    In GetSubContainer() I insert 3 submenus (Object Mode, Selection Mode, UV Commands).
    When the user opens the plugin menu, the whole set of menu items is nicely shown as expected.

    As soon as the user undocks the menu, the submenus disappear and the empty menu entry of the "proxy" command plugin is shown, with a default icon. When the user selects this menu item a popup menu appears with the 3 submenus listed.

    I suppose that when a menu is undocked, it becomes some sort of palette, and the only way to show submenu is as a popup menu?
    Or is there anyway to make an undocked menu look similar to the original docked menu?



  • On 04/05/2017 at 01:13, xxxxxxxx wrote:

    Hi,

    Implementing GetSubContainer() should be enough.
    Could you post the code you use in GetSubContainer() to insert the 3 sub-menus?



  • On 04/05/2017 at 10:25, xxxxxxxx wrote:

    Here's the full implementation of the CommandData plugin.
    Note that all ID_x and IDS_x are defined in c4d_symbols.h and c4d_strings.h
    These are simply numbered ID_1 ... ID_n for demonstration purpose.

      
    class CustomMenuOrder : public CommandData  
    {  
    public:  
      virtual Bool Execute(BaseDocument* doc);  
      virtual Bool ExecuteSubID(BaseDocument* doc, Int32 subid);  
      virtual Int32 GetState(BaseDocument* doc);  
      virtual Bool GetSubContainer(BaseDocument* doc, BaseContainer& submenu);  
    };  
      
    Bool CustomMenuOrder::Execute(BaseDocument* doc)  
    {  
      return true;  
    }  
    Bool CustomMenuOrder::ExecuteSubID(BaseDocument* doc, Int32 subid)  
    {  
      // pass the selected submenu ID to the main UV View Command plugin  
      CallCommand(UVVIEW_PLUGIN_ID, subid);  
      return true;  
    }  
    Int32 CustomMenuOrder::GetState(BaseDocument* doc)  
    {  
      return CMD_ENABLED;  
    }  
      
    Bool CustomMenuOrder::GetSubContainer(BaseDocument* doc, BaseContainer& submenu)  
    {  
      BaseContainer bcObjMode;  
      bcObjMode.SetString(1, GeLoadString(IDS_UVVIEW_OBJECTMODE));  
      bcObjMode.SetString(ID_1, GeLoadString(IDS_1));  
      bcObjMode.SetString(ID_2, GeLoadString(IDS_2));  
      submenu.InsData(0, bcObjMode);  
      
      BaseContainer bcSelMode;  
      bcSelMode.SetString(1, GeLoadString(IDS_UVVIEW_SELECTIONMODE));  
      bcSelMode.SetString(ID_3, GeLoadString(IDS_3));  
      bcSelMode.SetString(ID_4, GeLoadString(IDS_4));  
      bcSelMode.SetString(ID_5, GeLoadString(IDS_5));  
      bcSelMode.SetString(ID_6, GeLoadString(IDS_6));  
      submenu.InsData(0, bcSelMode);  
      
      BaseContainer bcCmds;  
      bcCmds.SetString(1, GeLoadString(IDS_UVVIEW_COMMANDS));  
      bcCmds.SetString(ID_7, GeLoadString(IDS_7));  
      bcCmds.SetString(ID_8, GeLoadString(IDS_8));  
      bcCmds.SetString(ID_9, GeLoadString(IDS_9));  
      bcCmds.SetString(ID_10, GeLoadString(IDS_10));  
      bcCmds.SetString(ID_11, GeLoadString(IDS_11));  
      submenu.InsData(0, bcCmds);  
      
      return true;  
    }  
      
    Bool RegisterCustomMenuOrder(void)  
    {  
      return RegisterCommandPlugin(  
          CUSTOM_MENUORDER_PLUGINID,  
          GeLoadString(IDS_UVVIEW_CUSTOMMENUORDER),  
          0,  
          0,  
          "",  
          NewObjClear(CustomMenuOrder));  
    }  
    


  • On 05/05/2017 at 02:34, xxxxxxxx wrote:

    Hi,

    I'm sorry I won't be able to investigate much your issue these days as next week we have MAXON's development meeting (See SDK Team at MAXON's Dev Meeting post).

    You can try to use FIRST_POPUP_ID or maybe even better ID_TREEVIEW_FIRST_NEW_ID (even if you're not showing a popup menu inside a TreeView) as base ID for the  SetString(id, string) calls, except for the   SetString(1, string) that sets the sub-menu title.



  • On 05/05/2017 at 04:50, xxxxxxxx wrote:

    Hi Yannick,
    Thanks for reminding me of the potential ID clashes.
    However, I tried ID_TREEVIEW_FIRST_NEW_ID, and even tried ID_TREEVIEW_FIRST_NEW_ID * 2 to make sure I was in the safe zone of IDs. But same issue as with the original IDs. No difference at all.

    So, I'll wait for the return of the SDK support team



  • On 23/05/2017 at 23:35, xxxxxxxx wrote:

    I'd like to bring this back to your attention, in case it slipped through.



  • On 24/05/2017 at 04:58, xxxxxxxx wrote:

    Hi,

    Thanks for the reminder 🙂

    The issue is dynamically submenus added from GetSubContainer() can't be converted into a palette buttons.  Only commands are supported. This explains why the undocked menu only displays the dummy command icon, and not its dynamic submenus.
    You can see the same behavior if the "Plugins" menu is undocked. The menu items for each plugin are no longer shown directly, but accessible from "Plugins" command.



  • On 26/05/2017 at 01:11, xxxxxxxx wrote:

    Hello Yannick,
    I see what you mean with the "plugins" menu.
    Currently, my command plugin responsible for the custom menu is registered without icon and empty string. Hence the reason for this dummy command icon.
    As such, the only option I have is to provide a string and icon, so that these are displayed in case of undocked state.
    Alternatively, I could get rid of the grouping of commands in submenus, and let them all be shown in the main list, including some separators to "group" commands belonging together. But this might turn out to become a long list.

    Haven't figured out the separator solution yet, so will probably go for the first solution.
    Thanks for your time.


Log in to reply