Hello all,
2023R2, am using a menu on the main page with Menuselected being the event that causes the menu to do whatever. Also on this page is a WebListBox. I am using the ContextualMenuSelected, in the WebListBox.
After the page is shown, I can press and use the menu on the page - it works as expected.
If I right click on the WebListBox, I get the contextual menu - it too works as expected.
However, if I go back to the main pages menu it won’t even pop up. Leaving the page to another then going back to the main page - no change.
The MenuSelected event does not even get called…
What have I done wrong??
I have tried having code in both the PageShown as well as (separately) having the setup for both of the objects in a single method on the Page.
This is the setup code. It is called from the MainPage.Shown Event
Private Sub mnuSetup()
//------------------ For the Menu on the Main Page ------------//
Var NavMenu As New WebMenuItem("Navmenu")
NavMenu.AddMenuItem(New WebMenuItem("Today"))
NavMenu.AddMenuItem(New WebMenuItem("Tomorrow"))
NavMenu.AddMenuItem(New WebMenuItem("Next Week"))
NavMenu.AddMenuItem(New WebMenuItem("Create License"))
NavMenu.AddMenuItem(New WebMenuItem("Exit"))
// Assign the menu to the dates button
Var dateButton As New WebToolbarButton
dateButton.Style = WebToolbarButton.ButtonStyles.Menu
dateButton.Menu = NavMenu
dateButton.Caption = "Navigate"
datebutton.Icon = webpicture.BootstrapIcon("calendar-date")
// Self.MainPageToolBar.AddItem(dateButton)
// --------------------------------------------------------------------------------------------//
// ----------- For the ContextualMenu on the WebListBox _________________//
// Create menu and assign it to the control
Var menu As New WebMenuitem("menu")
menu.AddMenuItem(New WebMenuItem("Action"))
menu.AddMenuItem(New WebMenuItem("-")) // Separator
// A header
Var item As New WebMenuItem("Options Header")
item.Style = WebMenuItem.Styles.Header
menu.AddMenuItem item
// A disabled item
item = New WebMenuItem("Disabled")
item.Enabled = False
menu.AddMenuItem item
// A menu with sub-items
item = New WebMenuItem("Parent")
item.AddMenuItem(New WebMenuItem("Child 1"))
item.AddMenuItem(New WebMenuItem("Child 2"))
item.AddMenuItem(New WebMenuItem("Child 3"))
menu.AddMenuItem item
// An item with a custom text color
item = New WebMenuItem("Restart")
item.TextColor = Color.Red
menu.AddMenuItem item
Self.lstSiteMaster.ContextualMenu = menu
End Sub
This is the code in the Menu.MenuSelected
Sub MenuSelected(Item as WebToolbarButton, hitItem as WebMenuItem) Handles MenuSelected
If item.Caption = "Navigate" Then
Select Case hitItem.Text
case "Create License"
Session.ShowLicensePage
case "Exit"
Session.ShowLoginPage
End Select
End If
hitItem.Text= "Hit Item"
MessageBox "Hit Item = " + hitItem.Text
Exception e as RuntimeException
Flds()= array("EXCEPTION", CurrentMethodName, Cstr( e.Type) )
Logs.AddFields Flds
Logs.LogFileAppend( Logs.K_Except_App_Err)
End Sub
This is the code in the WebListBox.ContextualMenuSelected event.
Sub ContextualMenuSelected(hitItem as WebMenuItem) Handles ContextualMenuSelected
MessageBox("You Selected """ + hitItem.Text + """")
End Sub
Ideas are appreciated!
Tim