Restricting a Command to a GeDialog



  • On 03/12/2016 at 11:21, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   R16-R18 
    Platform:   Windows  ;   
    Language(s) :

    ---------
    Hi,
    I'd like to implement a CommandData-based plugin where its shortcut is restricted to a specific custom GeDialog. Is it possible to have some brief example code showing how to achieve this?

    Thanks



  • On 05/12/2016 at 08:09, xxxxxxxx wrote:

    Hi,

    yes, this is possible and actually used quite heavily inside C4D.
    In your CommandData you need to implement the Message() function and react to message MSG_COMMANDINFORMATION. There you need to fill the passed CommandInformationData structure.
    In your case it is enough to set the "managergroup" to the ID passed to the Open() function of your dialog (usually the ID of the CommandData hosting the dialog).

    The "parentid" member of the CommandInformationData might also be interesting (to be used in combination with above managergroup). There you can pass the ID of a parent command. For example you have implemented your own "Select All" command and want it to look and behave like all other "Select All" commands in C4D. Then you'd pass IDM_SELECTALL as parentid. By this your command will automatically inherit the icon, tooltip and hotkey assignment from the parent command.

    For example:

    Bool MyCommandData::Message(Int32 type, void *t_data)
    {
    	CommandInformationData *cid = (CommandInformationData* )t_data;
    	if (type == MSG_COMMANDINFORMATION && cid)
    	{
    		cid->managergroup = ID_COMMAND_OPEN_MY_DIALOG;
    		if (cid->command_id == ID_COMMAND_MY_SELECT_ALL)
    			cid->parentid = IDM_SELECTALL;
    	}
    	return true;
    }
    

    Edit: Added example code



  • On 05/12/2016 at 08:50, xxxxxxxx wrote:

    Thanks Andreas.
    This is exactly what I wanted to do.
    I've found BTW that if commands that have a parent, specify their own string name via RegisterPlugin then I get a an assert from:

    p:\c4d_perforce_work\release\18.0\modules\c4dplugin\source\src	ilo\resourcefiles\res_command.cpp(500) : CRITICAL: Stop  
    

    But by using an empty string instead I get the default (hopefully localized) text for the command I'm inheriting from.

    Another question:
    In my plugin, I'm using the command id as the parameter to GeDialog::Open. How would I go about registering this window as being a manager also visible in the "Restrict To" option of the "Customize Commands" C4D window?
    I know RegisterManagerInformation sort of does this, but how can I associate this "manager" with my GeDialog? Should I just use the same pluginId or just use the manager's uniqueid  when calling GeDialog::Open?

    Thanks

    Edit:
    Jumped the gun a little bit. I think the above assert may be caused when a single keyboard shortcut maps to multiple commands.



  • On 05/12/2016 at 09:13, xxxxxxxx wrote:

    Hm, I'm not sure you need to anything special for a manager dialog to appear in that list.
    You register your command, which hosts the dialog just as usual. And in the command you implement the usual suspects Execute() (opening the dialog, passing the ID of the command plugin) and RestoreLayout() (well, restoring the layout).
    At least for this seems to be enough to make my manager appear in the "Restrict to" list in Customize Commands.



  • On 28/04/2017 at 00:53, xxxxxxxx wrote:

    Thanks for this information, it was really useful.
    However, I don't seem to get my CommandData plugin in the list of restriction.
    Should I see the string, used to register the plugin, in the restriction list?
    Currently I only see an "Tool Overwrite" entry at the bottom of the list. Don't know if this is present by default, or as a result of some plugins?



  • On 28/04/2017 at 02:29, xxxxxxxx wrote:

    I have to admit, I gave wrong (or at least incomplete) information here. Very, very sorry!
    A bit surprised Kostas didn't get back to me on this... he must have run into the same issue. Sorry, Kostas, please don't hesitate to bug me, if my information seems wrong.

    The point is, you also need to use RegisterManagerInformation() with the command ID you use to open the manager dialog.

    Again, I apologize to everyone getting confused by my above posts.



  • On 28/04/2017 at 03:05, xxxxxxxx wrote:

    Andreas, thanks for the update. Although it was mentioned in previous messages, I missed that bit about the need to use RegisterManagerInformation().

    Just wondering what the 3rd parameter actually represents (the manager's info flags: PLUGINFLAG), not sure I understand its purpose.



  • On 28/04/2017 at 05:32, xxxxxxxx wrote:

    Just pass a 0 for the info parameter. Maybe one could use it to hide this manager for example from the restriction list. But I really don't know and due to upcoming FMX and MAXON DevMeeting, I'm unfortunately lacking the time to dig into it. If you want me to investigate, please ask me in two weeks again.



  • On 01/05/2017 at 01:54, xxxxxxxx wrote:

    No need to dig deeper into the PLUGINFLAG right now. I'm fine using 0.

    However, further testing shortcuts I noticed a problem, which I am not sure is my mistake, or simply a limitation of the SDK.

    I have multiple plugins (tools and commands) which I wanted to see listed in a particular order in the plugin menu. For this I used the "#$n" in the stringtable, with increasing values for n, according to the requested sorting.
    When I assign a multi key shortcut (example Q~S) via the customize command, this "#$n" is shown in front of the plugin string, in the multi-key popup window when I press "Q".
    While in the menu, the "#$n" isn't shown.

    Is there something I am still missing? Or is this a limitation/feature/bug?



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

    Hi,

    I think, it's best to open a new thread for the last question. In this way, Yannick or Riccardo will see the question (otherwise they might think, I'm working on it).



  • On 01/05/2017 at 06:10, xxxxxxxx wrote:

    Will do.



  • On 03/05/2017 at 08:19, xxxxxxxx wrote:

    Hi Andreas
    No worries, it wasn't a super important feature to get working, more in the "nice-to-have" category.

    @C4DS,  not sure if it was the same issue as the one I was seeing, but make sure you leave a space after the "#$n", otherwise some parts of C4D will treat that as part of the description of the command.

    Cheers
    K.



  • On 03/05/2017 at 11:37, xxxxxxxx wrote:

    Adding a space doesn't help.
    But the issue with the "#$n"showing in the popup window has already been confirmed to be a bug (see separate thread).


Log in to reply