Coding style: Add context menu items via appendMenuItems, not RimContextCommandBuilder

This commit is contained in:
Magne Sjaastad
2026-06-01 11:10:07 +02:00
parent fe81dd8f3e
commit c722aa83e5
+14
View File
@@ -136,6 +136,20 @@ addNewButton( "Apply", [this]() { onApplyClicked(); } );
void MyClass::onApplyClicked() { /* complex logic here */ }
```
### Context Menus
When adding or modifying context-menu items for a PDM object, override `appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder )` on that object and add the entries there.
- Do **not** modify `RimContextCommandBuilder` to add object-specific menu items. It dispatches to each object's `appendMenuItems`; keep object-specific logic in the object.
```cpp
// Good menu items added in the object's own appendMenuItems override
void RimFoo::appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const
{
menuBuilder << "RicSomeFeature";
}
```
## Commit Conventions
When creating commits: