From 53f15482e0921a9a9305f29810c38e251390f16a Mon Sep 17 00:00:00 2001 From: Kai O'Reilly Date: Fri, 5 Jul 2024 13:45:00 -0700 Subject: [PATCH] finish fixing code command icon handling --- code/appbar.go | 41 +++++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/code/appbar.go b/code/appbar.go index eb9171bc..67555182 100644 --- a/code/appbar.go +++ b/code/appbar.go @@ -5,8 +5,6 @@ package code import ( - "strings" - "cogentcore.org/core/core" "cogentcore.org/core/events" "cogentcore.org/core/filetree" @@ -132,26 +130,25 @@ func (cv *Code) MakeToolbar(p *tree.Plan) { //types:add }) tree.Add(p, func(w *core.Button) { - w.SetText("Command"). - SetShortcut(KeyExecCmd.Chord()). - SetMenu(func(m *core.Scene) { - ec := ExecCmds(cv) - for _, cc := range ec { - cc := cc - cat := cc[0] - ic := icons.Icon(strings.ToLower(cat)) - core.NewButton(m).SetText(cat).SetIcon(ic).SetMenu(func(mm *core.Scene) { - nc := len(cc) - for i := 1; i < nc; i++ { - cm := cc[i] - core.NewButton(mm).SetText(cm).SetIcon(ic).OnClick(func(e events.Event) { - e.SetHandled() - cv.ExecCmdNameActive(CommandName(cat, cm)) - }) - } - }) - } - }) + w.SetText("Command").SetShortcut(KeyExecCmd.Chord()) + w.SetMenu(func(m *core.Scene) { + ec := ExecCmds(cv) + for _, cc := range ec { + cc := cc + cat := cc[0] + icon := CommandIcons[cat] + core.NewButton(m).SetText(cat).SetIcon(icon).SetMenu(func(mm *core.Scene) { + nc := len(cc) + for i := 1; i < nc; i++ { + cm := cc[i] + core.NewButton(mm).SetText(cm).SetIcon(icon).OnClick(func(e events.Event) { + e.SetHandled() + cv.ExecCmdNameActive(CommandName(cat, cm)) + }) + } + }) + } + }) }) tree.Add(p, func(w *core.Separator) {})