Does anyone know where I can find an example of how to build a dynamic hierarchical popup menu? I know that it should be simple with judicious use of “Child” menus and the like, but it’s early Sunday and my brain isn’t working quite yet. It will all be built in the MouseDown event. The documentation about this is scarce to non-existant. Thanks.
I have a “Share” button, and when the user clicks on it I want to pop up the something like the following:
Edit...
MenuItem.TextSeparator
Send To >
Email
iPhoto
Flickr
Twitter
Open in >
Photoshop
Acorn
blah
blah
Michel, despite it’s title, that post doesn’t actually talk about multi layer hierarchical dynamic menus. I’ll keep searching…
This did it. I still have to write the code to find all the appropriate applications, etc., and I’ll keep the menus as window properties, this way they can be built only once at launch, but this is the general idea:
Function MouseDown(X As Integer, Y As Integer) As Boolean
Dim mnuPopup As New MenuItem
Dim mnuSendTo As New MenuItem
Dim mnuOpenIn As New MenuItem
Dim selectedMenu As MenuItem
mnuSendTo.Text = "Send To..."
mnuSendTo.Append(New MenuItem("Email"))
mnuSendTo.Append(New MenuItem("Flickr"))
mnuSendTo.Append(New MenuItem("Facebook"))
mnuSendTo.Append(New MenuItem("Twitter"))
mnuOpenIn.Text = "Open In"
mnuOpenIn.Append(New MenuItem("Photoshop"))
mnuOpenIn.Append(New MenuItem("Acorn"))
mnuOpenIn.Append(New MenuItem("Photos"))
mnuPopup.Append(New MenuItem("Edit"))
mnuPopup.Append(New MenuItem(MenuItem.TextSeparator))
mnuPopup.Append(mnuSendTo)
mnuPopup.Append(mnuOpenIn)
selectedMenu = mnuPopup.PopUp
If selectedMenu <> Nil Then
Select Case selectedMenu.Text
'Do lots of interesting things here...
End Select
End If
Return True
End Function