Feature request: IDE Component Tree 'Collapse All'
Lazarus 4.99 (rev main_4_99-3989-gd2b4b2bfb6) FPC 3.2.3 aarch64-darwin-cocoa # What Happens? When I select or open a form in the Form Designer, the Object Inspector Component Tree defaults to showing the entire tree hierarchy fully expanded. I find this makes it difficult to find the bit of the form I'm interested in, especially if there are complex components with many nodes, such as SynEdit, present on the form. There can be a lot to scroll through. # Request Could we add an Option for the Component Tree to default to 'all nodes collapsed' initially, so that we can then expand just the part we're currently working on. Alternatively a 'Collapse All' menu item on the right-click context menu would help too. # Potential ideal behaviour An 'Auto Collapse' checkbox option in IDE Options \> Environment \> Object Inspector, so when we select a component on the form, just that part of the Component Tree expands, and all other nodes auto-collapse. That way the Component Tree always stays focused on the task at hand. # Considerations Context menus can get quite long. Adding a 'Collapse All' item lengthens it further. ![ComponentTreeCollapseAll.png](/uploads/0b2b0177631cf1196427b848acc289d6/ComponentTreeCollapseAll.png){width=426 height=256} # Hack In case it helps, I’ve temporarily hacked in a popup context menu item in ObjectInspector.pp like this: ``` procedure TObjectInspectorDlg.CollapseAllTreeNodes(Sender: TObject); begin ComponentTree.FullCollapse; ComponentTree.TopItem.Expand(False); //No need to collapse the root itself. end; procedure TObjectInspectorDlg.MainPopupMenuPopup(Sender: TObject); … procedure AddCollapseAllMenuItem(Index: Integer); var NewItem, NewSep: TMenuItem; begin NewItem := TMenuItem.Create(MainPopupMenu); NewItem.Caption := 'Collapse All'; NewItem.Name:=ComponentEditorMIPrefix+NewItem.Name; NewItem.OnClick := @CollapseAllTreeNodes; MainPopupMenu.Items.Insert(Index, NewItem); NewSep:=NewLine; NewSep.Name:=ComponentEditorMIPrefix+NewSep.Name; MainPopupMenu.Items.Insert(Index, NewSep); end; procedure AddComponentEditorMenuItems; … AddCollapseAllMenuItem(VerbCount); end; ``` …not the ideal place for it, but it does work :) I don't feel confident enough to create a patch as I don't yet understand the Verb system here. Link to topic on the forum: https://forum.lazarus.freepascal.org/index.php/topic,73931.0.html
issue