Unable to create a Menu outside the top Menu Bar

tauseefAhmed
Posts: 38
Joined: Wed Jul 31, 2019 4:56 pm

Unable to create a Menu outside the top Menu Bar

Postby tauseefAhmed » Mon Jul 06, 2020 4:17 am

Hello, I'm trying to create a Menu using IMenuService & IMenuObject.
I have followed CustomPDKObjects sample provided with SDK but it creates the Menu in top menu bar.
I have tried to change the Menu Type parameter with all given menu types but no joy.
Is there any way around to create a Menu not in the Top Menu Bar but anywhere on the screen. Just like mouse right click opens a menu. A context Menu (if that's the correct name P3D has for such menu items).
Also, the menu item can only be a static text or a checkbox. I want to make it editable. For example I want to create a Menu Item as follows:
______________
|Camera Pitch 10|
such that I can change the pitch value by a keyboard event and press enter, now my camera sets that pitch value.
Does P3D have a sample/mechanism for that?


Regards,
Tauseef

User avatar
Beau Hollis
Lockheed Martin
Posts: 2148
Joined: Wed Oct 06, 2010 3:25 pm

Re: Unable to create a Menu outside the top Menu Bar

Postby Beau Hollis » Thu Aug 20, 2020 1:46 pm

The menu item has a setter for the name, so it should be possible to change. Worse case you could remove and re-add when the name changes. As for context menu support, we build the context menu in a callback when the right click is detected, so i don't think adding directly to it would work. The menu id for the context root is 0x0002 if you want to experiment with it. What might work is adding your item to one of the camera menus we add to the context menu. You could try 0x0408 which is the context menu camera menu id. It's likely though that we clear and repopulate it dynamically it may not work and/or might get things into a bad state.

EDIIT: It's also worth noting that part of why we don't publish the other menu IDs in the menu service header is to avoid an add-on braking the menu by trying to remove or relocate menu items. The menu structure is a tree with some special allowances for because an item could have more than one parent if it is on the context and menu bar. The recursive traversal of the tree could go awry if for example an menu item had a child that was also a parent or grandparent, or if the same item were added to multiple places in the tree.
Beau Hollis
Prepar3D Software Architect


Return to “Software Development Kit (SDK) Questions”

Who is online

Users browsing this forum: No registered users and 12 guests