B4J Question Changing MenuItem prompt after initialization [solved]

Discussion in 'B4J Questions' started by Didier9, May 18, 2019.

  1. Didier9

    Didier9 Active Member Licensed User

    I would like to be able to change the prompt of a MenuItem after it has been initialized. Is it possible?
     
  2. Erel

    Erel Administrator Staff Member Licensed User

  3. Didier9

    Didier9 Active Member Licensed User

    Thank you, a little more complicated than I was hoping for but will get the job done :)
     
  4. Didier9

    Didier9 Active Member Licensed User

    I did find a simpler way. It's certainly a less general answer but it works well enough for me at the moment.
    Instead of using the code as I have seen in the examples where the submenu m is declared locally in App_Start():
    Code:
    Sub App_Start(...)
        
    ' create top level menu entry
        Dim TopMenu As Menu
        TopMenu.Initialize( 
    "Top Menu""" )
        mb.Menus.Add( TopMenu )
        
    ' Add submenu
        Dim m As MenuItem
        m.Initialize( 
    "Sub Menu""mSubMenu" )
        TopMenu.MenuItems.Add( m )
    I declare the sub menu as a process global variable:
    Code:
    Sub Process_Globals
        
    Private m1 as MenuItem
    End Sub
    Sub App_Start(...)
        
    ' create top level menu entry
        Dim TopMenu As Menu
        TopMenu.Initialize( 
    "Top Menu""" )
        mb.Menus.Add( TopMenu )
        
    ' Add submenu
        m1.Initialize( "Sub Menu""mSubMenu" )
        TopMenu.MenuItems.Add( m1 )
    and when I want to change the prompt anywhere in the code:
    Code:
    m1.Text = "bla bla"
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice