Hello
I'm trying to make a class to use a B4XDrawer in several B4XPages.
I've made a small project but it's not working.
After 2-3 clicks in menu it stacks for some time and then continues for a click and stucks again.
Please can anyone check this?
Thank you
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
Page 2 and 3 is similar to 1
			
			I'm trying to make a class to use a B4XDrawer in several B4XPages.
I've made a small project but it's not working.
After 2-3 clicks in menu it stacks for some time and then continues for a click and stucks again.
Please can anyone check this?
Thank you
			
				The class:
			
		
		
		Sub Class_Globals
    Private Root As B4XView 'ignore
    Private xui As XUI
    'Drawer Menu
    Private drMen As B4XDrawer
    Private HamburgerIcon As B4XBitmap
   
    Private MenuItems As ListView
    Private Menus As List
    Private stringModuleName  As String
    Dim cs As CSBuilder
End Sub
'Initializes the object. You can add parameters to this method if needed.
Public Sub Initialize(page As String, Parent As B4XView)
    stringModuleName = page
    drMen.Initialize(Me, "Drawer", Parent, 200dip)
   
    Menus.Initialize
    Menus.AddAll (Array As String("Page1", "Page2", "Page3"))
   
    drMen.LeftPanel.LoadLayout("drawerMenu")
    drMen.CenterPanel.LoadLayout(page)
    HamburgerIcon = xui.LoadBitmapResize(File.DirAssets, "hamburger.png", 32dip, 32dip, True)
'    Place items one by one with icons
'    MenuItems.SingleLineLayout.Label.TextSize = 20
'    MenuItems.AddSingleLine( cs.Initialize.Typeface(Typeface.MATERIALICONS).Size(22).VerticalAlign(3dip).Append(Chr(0xE145)).PopAll.Append("  Page 1") )
'    MenuItems.AddSingleLine( cs.Initialize.Typeface(Typeface.MATERIALICONS).Size(22).VerticalAlign(3dip).Append(Chr(0xF080)).PopAll.Append("  Page 2") )
'    MenuItems.AddSingleLine( cs.Initialize.Typeface(Typeface.MATERIALICONS).Size(22).VerticalAlign(3dip).Append(Chr(0xF013)).PopAll.Append("  Page 3") )
'    Use list with menu items
    For i = 0 To Menus.Size -1
        MenuItems.AddSingleLine(Menus.Get(i))
    Next
End Sub
Public Sub pageAppear
    #if B4A
    Sleep(0)
    B4XPages.GetManager.ActionBar.RunMethod("setDisplayHomeAsUpEnabled", Array(True))
    Dim bd As BitmapDrawable
    bd.Initialize(HamburgerIcon)
    B4XPages.GetManager.ActionBar.RunMethod("setHomeAsUpIndicator", Array(bd))
    #End If
End Sub
Public Sub closePage As Boolean
    #if B4A
    If Main.ActionBarHomeClicked Then
        drMen.LeftOpen = Not(drMen.LeftOpen)
        Return False
    End If
    'back key
    If drMen.LeftOpen Then
        drMen.LeftOpen = False
        Return False
    End If
    #end if
    Return True
End Sub
Public Sub resize(Width As Int, Height As Int)
    drMen.Resize(Width, Height)
End Sub
'App menu
Public Sub MenuItems_ItemClick (Position As Int, Value As Object)
'    Dim p As Panel = Sender
    drMen.LeftOpen = Not(drMen.LeftOpen)
    Select Value
        Case "Page1"
            If stringModuleName <> "Page1"  Then
                Log("page1 clicked")
                B4XPages.ShowPage("mainpage")
'                B4XPages.ShowPageandRemovePreviousPages("MainPage")
            End If
        Case "Page2"
            If stringModuleName <> "Page2"  Then
                Log("page2 clicked")
                B4XPages.ShowPage("Page2")
'                B4XPages.ShowPageandRemovePreviousPages("Page2")
            End If
        Case "Page3"
            If stringModuleName <> "Page3"  Then
                Log("page3 clicked")
                B4XPages.ShowPage("Page3")
'                B4XPages.ShowPageandRemovePreviousPages("Page3")
            End If
    End Select
End Sub
	
			
				MainPage:
			
		
		
		'Ctrl + click to export as zip: ide://run?=&File=%B4X%\Zipper.jar&Args=Project.zip
Sub Class_Globals
    Private Root As B4XView 'ignore
    Private xui As XUI 'ignore
    Public Page2 As B4XPage2
    Public Page3 As B4XPage3
   
    Private drawer As menuDrawer
End Sub
'You can add more parameters here.
Public Sub Initialize
End Sub
'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    'load the layout to Root
   
    drawer.Initialize("frmPage1", Root)
    B4XPages.SetTitle(Me, "Page1")
   
    Page2.Initialize
    B4XPages.AddPage("Page2", Page2)
    Page3.Initialize
    B4XPages.AddPage("Page3", Page3)
End Sub
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
Private Sub B4XPage_Appear
    drawer.pageAppear
End Sub
Private Sub B4XPage_CloseRequest As ResumableSub
    Return drawer.closePage
End Sub
Private Sub B4XPage_Disappear
    #if B4A
    B4XPages.GetManager.ActionBar.RunMethod("setHomeAsUpIndicator", Array(0))
    #end if
End Sub
Private Sub B4XPage_Resize (Width As Int, Height As Int)
    drawer.resize(Width, Height)
End Sub
	Page 2 and 3 is similar to 1
Attachments
			
				Last edited: