C++ - Custom application commands

Post questions, comments and feedback to our 3Dconnexion Windows Development Team.

Moderator: Moderators

Post Reply
Valzul
Posts: 6
Joined: Fri Sep 06, 2024 12:15 am

C++ - Custom application commands

Post by Valzul »

Hello,

Is anyone having trouble to create custom application commands for the button click ?
It seems I can get it to work sometimes after rebuilding my application, but sometimes nothing happens.
I can't get it to consistently populate the menu ( there should be a menu with the profile name set to nav3d interface here if I understand correctly ) :

Image

Here is the code I'm currently using to create a list of custom commands based on what I saw in the navlib_viewer project :

Code: Select all

  using TDx::SpaceMouse::CCategory;
  using TDx::SpaceMouse::CCommand;
  using TDx::SpaceMouse::CCommandSet;
  
  // The root action set node
  CCommandSet commandSet("Default", "Modeling");

  // CCategory category("MenuItem Category", "Category");
  CCommand command("MenuItem Command","Command");
  CCommand command1("MenuItem Command1","Command1");
  CCommand command2("MenuItem Command2","Command2");
  commandSet.push_back(std::move(command));
  commandSet.push_back(std::move(command1));
  commandSet.push_back(std::move(command2));
  // commandSet.push_back(std::move(category));

  // CCategory category1("MenuItem Category1", "Category1");
  CCommand command3("MenuItem Command3","Command3");
  CCommand command4("MenuItem Command4","Command4");
  CCommand command5("MenuItem Command5","Command5");
  commandSet.push_back(std::move(command3));
  commandSet.push_back(std::move(command4));
  commandSet.push_back(std::move(command5));
  // commandSet.push_back(std::move(category1));

  // commandSet.push_back(std::move(category));
  nav3d::AddCommandSet(commandSet);
  nav3d::ActiveCommands = commandSet.Id;
  
I tried playing around with the push_back of categories or commands, but I can't make it work all the time ...

What am I doing wrong ?
ngomes
Moderator
Moderator
Posts: 3391
Joined: Mon Nov 27, 2006 7:22 am
Contact:

Re: C++ - Custom application commands

Post by ngomes »

Valzul wrote: Mon Sep 23, 2024 2:42 am What am I doing wrong ?
The code seems fine.

Did you see the same issue with the "navlib_viewer" sample?

Check if there is a driver configuration file for your application in %APPDATA%\3Dconnexion\3DxWare\Cfg

If there is, exit your program, delete that configuration and try again. We may need to look into this.
Nuno Gomes
Valzul
Posts: 6
Joined: Fri Sep 06, 2024 12:15 am

Re: C++ - Custom application commands

Post by Valzul »

I didn't see the same issue on the navlib_viewer.

I deleted the configuration files that were located in %APPDATA%\3Dconnexion\3DxWare\Cfg and now it looks like I've got it working ( while testing the navlib example, I modified the profile name to be the same as my own C++ application, which I corrected too to make sure the config file would not be overwritten ).

The fact that the menu take a bit of time to fully load ( perhaps loading all icons ? ) caught me off guard, and many times when I was checking, I opened the menu before the loading was done I believe, so I didn't got my own list of items :

Icons are not present, the custom configuration is still not loaded :

Image

Wait a bit, then it is loaded correctly :

Image

I am now able to see the CCommand I configured in my application, but can't make any category appears ... :

Code: Select all

  // The root action set node
  CCommandSet commandSet("Default", "Modeling");

  CCategory cat_example("Example category", "Example category");
  CCommand cmd_example("0", "Custom command", "Custom command description");
  cat_example.push_back(std::move(cmd_example));
  commandSet.push_back(std::move(cat_example));

  nav3d::AddCommandSet(commandSet);
  nav3d::ActiveCommands = commandSet.Id;
In this case, the command appears on the main menu of my application, but the category does not.
ngomes
Moderator
Moderator
Posts: 3391
Joined: Mon Nov 27, 2006 7:22 am
Contact:

Re: C++ - Custom application commands

Post by ngomes »

Valzul wrote: Mon Sep 23, 2024 6:11 am In this case, the command appears on the main menu of my application, but the category does not.
Again, the code seems fine but try removing the space character in the category identifier.

For example, use a underscore character like "Example_category".
ngomes
Moderator
Moderator
Posts: 3391
Joined: Mon Nov 27, 2006 7:22 am
Contact:

Re: C++ - Custom application commands

Post by ngomes »

I had a word internally.

If there is only one category, then commands are listed directly under the action set name.

Try adding more categories. You should see them listed.
Valzul
Posts: 6
Joined: Fri Sep 06, 2024 12:15 am

Re: C++ - Custom application commands

Post by Valzul »

Here is the current code, I tried category names without spaces :

Code: Select all

  CCommandSet commandSet("Default", "Modeling");

  CCategory view_cat("Vues", "Vues");
  CCategory macro_cat("Macro", "Macro");

  commandSet.push_back(std::move(view_cat));
  commandSet.push_back(std::move(macro_cat));

  CCommand cmd_example("0", "Custom command", "Custom command description");
  commandSet.push_back(std::move(cmd_example));
  
  nav3d::AddCommandSet(commandSet);
  nav3d::ActiveCommands = commandSet.Id;
 
But it doesn't show categories at all, commands added to the commandSet do work though :

Image
ngomes
Moderator
Moderator
Posts: 3391
Joined: Mon Nov 27, 2006 7:22 am
Contact:

Re: C++ - Custom application commands

Post by ngomes »

Empty categories are not shown. Try adding at least one CCommand to each CCategory object.
Valzul
Posts: 6
Joined: Fri Sep 06, 2024 12:15 am

Re: C++ - Custom application commands

Post by Valzul »

It works !

Thanks for the help ngomes and my regards to the team :D
Post Reply