# 2023R2 Using ContextualMenuSelected kills Menuselected

**URL:** <https://forum.xojo.com/t/2023r2-using-contextualmenuselected-kills-menuselected/77407>\
**Category:** Web\
**Created:** [September 26, 2023, 6:00am UTC](https://forum.xojo.com/t/2023r2-using-contextualmenuselected-kills-menuselected/77407 "2023-09-26T06:00:05Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tim\_Seyfarth](https://forum.xojo.com/letter_avatar_proxy/v4/letter/t/d26b3c/32.png) [@Tim\_Seyfarth](https://forum.xojo.com/u/Tim_Seyfarth)\
**Post date:** [September 26, 2023, 6:00am UTC](https://forum.xojo.com/t/2023r2-using-contextualmenuselected-kills-menuselected/77407/1 "2023-09-26T06:00:05Z")

</div>

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

```auto
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

```auto
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.

```auto
Sub ContextualMenuSelected(hitItem as WebMenuItem) Handles ContextualMenuSelected
  MessageBox("You Selected """ + hitItem.Text + """")
End Sub

```

Ideas are appreciated!

Tim

---

<div class="post-metadata">

**Author:** ![Tim\_Seyfarth](https://forum.xojo.com/letter_avatar_proxy/v4/letter/t/d26b3c/32.png) [@Tim\_Seyfarth](https://forum.xojo.com/u/Tim_Seyfarth)\
**Post date:** [September 27, 2023, 8:14pm UTC](https://forum.xojo.com/t/2023r2-using-contextualmenuselected-kills-menuselected/77407/2 "2023-09-27T20:14:11Z")

</div>

Anybody on this?  
Tim

---

<div class="post-metadata">

**Author:** ![Ricardo\_Cruz](https://forum.xojo.com/user_avatar/forum.xojo.com/ricardo_cruz/32/7852_2.png) [@Ricardo\_Cruz](https://forum.xojo.com/u/Ricardo_Cruz)\
**Post date:** [September 27, 2023, 11:01pm UTC](https://forum.xojo.com/t/2023r2-using-contextualmenuselected-kills-menuselected/77407/3 "2023-09-27T23:01:06Z")

</div>

Can you please create a new issue with a sample project to review it?

---

<div class="post-metadata">

**Author:** ![Tim\_Seyfarth](https://forum.xojo.com/letter_avatar_proxy/v4/letter/t/d26b3c/32.png) [@Tim\_Seyfarth](https://forum.xojo.com/u/Tim_Seyfarth)\
**Post date:** [September 29, 2023, 1:31am UTC](https://forum.xojo.com/t/2023r2-using-contextualmenuselected-kills-menuselected/77407/4 "2023-09-29T01:31:18Z")

</div>

Created issue [74253](https://tracker.xojo.com/xojoinc/xojo/-/issues/74253)

Only thing is, I cannot find out where to upload the sample code I created. Can you advise please?

Tim

---

<div class="post-metadata">

**Author:** ![Greg\_O](https://forum.xojo.com/user_avatar/forum.xojo.com/greg_o/32/22785_2.png) [@Greg\_O](https://forum.xojo.com/u/Greg_O)\
**Post date:** [September 29, 2023, 2:59am UTC](https://forum.xojo.com/t/2023r2-using-contextualmenuselected-kills-menuselected/77407/5 "2023-09-29T02:59:11Z")

</div>

Just zip it and drag the file into the comment window.

---

<div class="post-metadata">

**Author:** ![Tim\_Seyfarth](https://forum.xojo.com/letter_avatar_proxy/v4/letter/t/d26b3c/32.png) [@Tim\_Seyfarth](https://forum.xojo.com/u/Tim_Seyfarth)\
**Post date:** [September 29, 2023, 6:31pm UTC](https://forum.xojo.com/t/2023r2-using-contextualmenuselected-kills-menuselected/77407/6 "2023-09-29T18:31:28Z")

</div>

Thanks Greg  
Tim

---

<div class="post-metadata">

**Author:** ![Ricardo\_Cruz](https://forum.xojo.com/user_avatar/forum.xojo.com/ricardo_cruz/32/7852_2.png) [@Ricardo\_Cruz](https://forum.xojo.com/u/Ricardo_Cruz)\
**Post date:** [October 2, 2023, 11:53am UTC](https://forum.xojo.com/t/2023r2-using-contextualmenuselected-kills-menuselected/77407/7 "2023-10-02T11:53:35Z")

</div>

Thank you for taking the time creating the Issue, it will be fixed in next release.

---

<div class="post-metadata">

**Author:** ![Tim\_Seyfarth](https://forum.xojo.com/letter_avatar_proxy/v4/letter/t/d26b3c/32.png) [@Tim\_Seyfarth](https://forum.xojo.com/u/Tim_Seyfarth)\
**Post date:** [October 2, 2023, 6:36pm UTC](https://forum.xojo.com/t/2023r2-using-contextualmenuselected-kills-menuselected/77407/8 "2023-10-02T18:36:00Z")

</div>

Hello Ricardo,

Sure, I guess it was an easy fix - that’s good!

Appreciated your prompt attention to this matter.  
Tim
