Added shortcut keys possibility to Menus

This commit is contained in:
Luke I. Wilson
2021-03-20 16:22:06 -05:00
parent fefa34c2b6
commit ce66bc4bc6
3 changed files with 49 additions and 20 deletions

View File

@@ -128,7 +128,7 @@ func main() {
},
)
changeFocus(fileSelector)
}}, &ui.ItemEntry{Name: "_Save", Callback: func() {
}}, &ui.ItemEntry{Name: "_Save", Shortcut: 's', Callback: func() {
if tabContainer.GetTabCount() > 0 {
tab := tabContainer.GetTab(tabContainer.GetSelectedTabIdx())
te := tab.Child.(*ui.TextEdit)
@@ -287,6 +287,13 @@ main_loop:
if ev.Key() == tcell.KeyCtrlQ { // TODO: replace with shortcut keys in menus
break main_loop
}
if ev.Modifiers() & tcell.ModCtrl != 0 {
handled := bar.HandleEvent(ev)
if handled {
continue // Avoid passing the event to the focusedComponent
}
}
}
focusedComponent.HandleEvent(ev)