gui: add helper function for menu separators

This commit is contained in:
mappu 2024-06-29 12:13:18 +12:00
parent d2b9618da0
commit 471737f421
2 changed files with 16 additions and 5 deletions

View File

@ -105,9 +105,7 @@ func (f *TMainForm) OnFormCreate(sender vcl.IObject) {
//
mnuSep := vcl.NewMenuItem(mnuFile)
mnuSep.SetCaption("-") // Creates separator
mnuFile.Add(mnuSep)
vcl_menuseparator(mnuFile)
mnuFileExit := vcl.NewMenuItem(mnuFile)
mnuFileExit.SetCaption("Exit")

View File

@ -30,9 +30,22 @@ func vcl_row(owner vcl.IWinControl, top int32) *vcl.TPanel {
func vcl_menuitem(parent *vcl.TMenuItem, caption string, imageIndex int32, onClick vcl.TNotifyEvent) *vcl.TMenuItem {
m := vcl.NewMenuItem(parent)
m.SetCaption(caption)
m.SetImageIndex(imageIndex)
m.SetOnClick(onClick)
if imageIndex != -1 {
m.SetImageIndex(imageIndex)
}
if onClick != nil {
m.SetOnClick(onClick)
}
parent.Add(m)
return m
}
// vcl_menuseparator adds a separator to the parent TMenuItem.
func vcl_menuseparator(parent *vcl.TMenuItem) *vcl.TMenuItem {
s := vcl.NewMenuItem(parent)
s.SetCaption("-") // Creates separator
parent.Add(s)
return s
}