How to do create/use sub menu on ToolBar

Hello all,

Can anyone explain or show sample code for creating and using a sub-menu on a toolbar? I have created normal menus, but have not figured out how to create a sub menu.

Thanks,
Tim

Did a menu in this pattern a couple of days ago:

Var m1 As DesktopMenuItem
Var myMenu As New DesktopMenuItem

Var subMen As New DesktopMenuItem
subMen.Text="Highlight"
subMen.Name="Highlight"

m1 = New DesktopMenuItem("SubText1")
m1.Tag="fromSub1"
subMen.AddMenu(m1)

m1 = New DesktopMenuItem("SubText2")
m1.Tag="fromSub2"
subMen.AddMenu(m1)

myMenu.AddMenu(subMen)

m1 = New DesktopMenuItem("Another")
m1.Tag="FromAnother"
myMenu.AddMenu(m1)

var tmp as DesktopMenuItem = myMenu.PopUp

If tmp<>Nil Then
  MessageBox(tmp.Tag)
end if

Thanks Keith!
Tim

Do you want something like this:

TimExample.xojo_binary_project.zip (5.7 KB)

2 Likes

@Tim_Seyfarth

There is an example with Xojo

Xojo IDE → Choose project →t examples → Platforms → Desktop → Toolbar

Thank you Brian - it is not a desktop app. But I will look in the samples anyway.
Thanks
TIm

BTW, the help using a non-existent function - .DropDownMenu

This code will not compile in 2025R2.1

chartButton.DropDownMenu = chartMenu

Opps! ok I totally missed that, Target → Web

Guess the flu is making me dizzy :laughing:

1 Like