gui: add query shortcut, or switch tab if not focused

This commit is contained in:
mappu 2024-06-15 12:14:32 +12:00
parent ef30a0d210
commit 5e0422e10f

16
main.go
View File

@ -77,9 +77,19 @@ func (f *TMainForm) OnFormCreate(sender vcl.IObject) {
mnuFileExit.SetOnClick(f.OnMnuFileExitClick) mnuFileExit.SetOnClick(f.OnMnuFileExitClick)
mnuFile.Add(mnuFileExit) mnuFile.Add(mnuFileExit)
mnuQuery := vcl.NewMenuItem(f)
mnuQuery.SetCaption("Query")
mnuQueryExecute := vcl.NewMenuItem(mnuQuery)
mnuQueryExecute.SetCaption("Execute")
mnuQueryExecute.SetShortCutFromString("F5")
mnuQueryExecute.SetOnClick(f.OnQueryExecute)
mnuQuery.Add(mnuQueryExecute)
f.Menu = vcl.NewMainMenu(f) f.Menu = vcl.NewMainMenu(f)
f.Menu.SetImages(f.ImageList) f.Menu.SetImages(f.ImageList)
f.Menu.Items().Add(mnuFile) f.Menu.Items().Add(mnuFile)
f.Menu.Items().Add(mnuQuery)
// //
@ -203,6 +213,12 @@ func (f *TMainForm) OnMnuFileExitClick(sender vcl.IObject) {
} }
func (f *TMainForm) OnQueryExecute(sender vcl.IObject) { func (f *TMainForm) OnQueryExecute(sender vcl.IObject) {
// If query tab is not selected, switch to it, but do not exec
if f.Tabs.ActivePageIndex() != 2 {
f.Tabs.SetActivePageIndex(2)
return
}
// Execute // Execute
node := f.Buckets.Selected() node := f.Buckets.Selected()
if node == nil { if node == nil {