Skip to content

Commit

Permalink
WIP - Handling submenu items getting highlighted.
Browse files Browse the repository at this point in the history
  • Loading branch information
austincondiff committed Dec 16, 2023
1 parent e185442 commit fc7bd9c
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion CodeEdit/Features/Editor/PathBar/Views/EditorPathBarMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit fc7bd9c

Please sign in to comment.