B4J Tutorial [BANanoWebix] Lesson 19 Contexts

Discussion in 'B4J Tutorials' started by Mashiane, Jun 30, 2019.

  1. Mashiane

    Mashiane Expert Licensed User


    This lesson is about the 'context' and 'contextmenu' widgets.

    Context are popups that one can use in case they want to provide some help on the UX. Both the context and context menus appear when the right mouse button is clicked and can be linked to any element on the page.

    In this example, we create two divs the normal way HTML components are defined and then we set the 'master' divs for the context and context menus.

    Each time one right clicks on the divs, the context and context menu appears. As these contexts are created during run time, they should be built after the page .UI method is called.


    First we create a row, then build our divs and inject to the row using the .SetTemplate method of the row. We set some background colors to the divs for our example.

        Dim R1 As WixRow
        'the body of the page is empty, lets create a div
        Dim div1 As UOENowHTML
        Dim div2 As UOENowHTML
        'get the body element
        Dim sb As StringBuilder
    We then add the row to the page and then execute .UI method of the page.

    Creating the Context

    The next step is to build the 'memory/runtime' contexts and link them to each of the divs.

    Dim context As WixContext '(popup)
    "Exterminate the Doctor! Exterminate! Exterminate!")
    As you right click on "div1" the context pop-up will show.

    Creating the ContextMenu

    The context-menu is a menu, thus all the operations related to the WixMenu will apply.

    Dim contextmenu As WixContextMenu
    contextmenu.AddItem("","sendto","Send To...","","","","")
    contextmenu.AddItem("","addcompanion","Add Companion","","","","")
    Dim data As List = pg.Unflatten(contextmenu.Items, "submenu")
        Dim meID As Map
    "contextmenu", BANano.CallBack(Me, "itemClick"Array(meID)))
    We add each of the menu items and then attach an event so that when each item of the menu is clicked we can do something.

    Sub itemClick(meid As String)
    End Sub
    joulongleu likes this.
  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