From fc7bd9c6e0b8036767761fa133790fc06bc06be7 Mon Sep 17 00:00:00 2001 From: Austin Condiff Date: Fri, 8 Dec 2023 09:43:14 -0600 Subject: [PATCH] WIP - Handling submenu items getting highlighted. --- .../PathBar/Views/EditorPathBarMenu.swift | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/CodeEdit/Features/Editor/PathBar/Views/EditorPathBarMenu.swift b/CodeEdit/Features/Editor/PathBar/Views/EditorPathBarMenu.swift index a319b5967..db4b9ceb7 100644 --- a/CodeEdit/Features/Editor/PathBar/Views/EditorPathBarMenu.swift +++ b/CodeEdit/Features/Editor/PathBar/Views/EditorPathBarMenu.swift @@ -45,10 +45,26 @@ final class EditorPathBarMenu: NSMenu, NSMenuDelegate { } // Highlight the current item - if let pathBarItem = item as? PathBarMenuItem { + if let pathBarItem = (item ?? menu.highlightedItem) as? PathBarMenuItem { + print(pathBarItem) pathBarItem.updateIconColor(isHighlighted: true) } + // If the item has a child menu with a selected item, recolor the icon + if let parentItem = item?.parent { + if let fileItem = item?.parent?.representedObject as? CEWorkspaceFile { + let icon = fileItem.systemImage + var color = NSColor(fileItem.iconColor) + if fileItem.isFolder { + color = NSColor(named: "FolderBlue") ?? NSColor(.secondary) + } + parentItem.image = NSImage( + systemSymbolName: icon, + accessibilityDescription: icon + )?.withSymbolConfiguration(.init(paletteColors: [color])) + } + } + if let highlightedItem = item, let submenuItems = highlightedItem.submenu?.items, submenuItems.isEmpty { if let highlightedFileItem = highlightedItem.representedObject as? CEWorkspaceFile { highlightedItem.submenu = generateSubmenu(highlightedFileItem)