Dev: Academy guide on group commands (toolbar drop-downs and submenus)
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 56/100
- Issue type
- Documentation
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- hugo
- Domain
- documentation
Research direction
Start by locating the Academy guide on creating toolbars in the website documentation and read how it is built. Add an example explaining grouped commands, their activation behavior and command type rules, plus guidance for finding valid menu names. Done when the guide covers these behaviors and answers how to identify menu entries.
Written by the indexing model from the issue text.
Description
Thank you for the great documentation on creating new toolbars.
Here is another useful example:
The command class (which is added via addCommand()) has an optional function named GetCommands(self) -> list[str]. You can return a list of command names to be grouped together. This new Group-Command can be used similar to a normal command item, but:
- In a toolbar it will display a drop-down list (like the Constraints or Circle combo menu).
- As a menu-item it will create a menu entry with all selected commands as submenu items.
There is also GetDefaultCommand(self) -> int which will trigger the command at chosen index (e.g. if user clicks on toolbar combo box without opening the drop-down).
The group can implement Activated(self, cmd: int = 0) -> None which provides the index of the performed action. If the group does NOT implement Activated(), the Activated() function of the child command is executed. If the group does implement Activated(), then the child is not called and the group is responsible for handling the action.
CmdType rules apply to the group first. E.g. if child command can be shown in edit mode, but group cannot, then you wont be able to call any child because the group will be deactivated.
...
As a related question: how to find valid menu names? E.g. I tried "Geometries" and it inserts a new menu item at the end of the "Sketch" menu. While this is where I want it to be, it is not where I would have expected the item to appear. I know the documentation says "names an entry, not a menu", but I dont know how to get either except by trial and error. Using an entry of a menu to append to that menu feels wrong, but I guess it is how it is.
- Dominant language
- HTML
- Stars
- 3
- Forks
- 10
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 27
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from FreeCAD/Website
-
Feature
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day
-
Help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
FreeCAD/Website#89 · 21 comments ·
Maintainers usually reply within 1 day
-
CMS Help wanted News Tools
Difficulty 5/5 Over a week Newbie friendliness 20/100
FreeCAD/Website#112 · 9 comments · 1 reaction ·
Maintainers usually reply within 1 day
-
Bug
Difficulty 4/5 3-5 days Newbie friendliness 45/100
FreeCAD/Website#111 · 26 comments · 2 reactions ·
Maintainers usually reply within 1 day
-
:octocat: Bug github_actions Hugo
Difficulty 4/5 3-5 days Newbie friendliness 45/100
FreeCAD/Website#105 · 4 comments ·
Maintainers usually reply within 1 day
Similar issues
-
ReferencesOpen
Difficulty 1/5 Under an hour Newbie friendliness 70/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
jaegertracing/documentation#1213 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
sky-map-team/stardroid#1422 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
eclipse-score/kyron#249 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
eclipse-score/logging#531 ·
Maintainers usually reply within 2 days