Oliver Simith
Member
Hi,
I implemented a custom class that creates and initializes a b4xdrawer for each page. (after reading this thread)
The left panels of the drawers use LayoutA, while the center panels use LayoutB and LayoutC with several buttons in each layout.
Although all buttons can be seen on the screen, the button_click events don't seem to work(no responses at all)
I guess there must be something that I did wrongly. Just don't know what it is and how to get it right.
What I've tried:
The code is like this:
The codes are:
I implemented a custom class that creates and initializes a b4xdrawer for each page. (after reading this thread)
The left panels of the drawers use LayoutA, while the center panels use LayoutB and LayoutC with several buttons in each layout.
Although all buttons can be seen on the screen, the button_click events don't seem to work(no responses at all)
I guess there must be something that I did wrongly. Just don't know what it is and how to get it right.
What I've tried:
- disable the customer class and do the initialization of a drawer in the page module, then it will work properly.
- disable the customer class and move drawer-related code into a custom sub of the page module, then it will work properly.
- tried to use breakpoints, the phenomenon was that the code flow didn't go to sub button4_click
The code is like this:
B4X:
****xDrawerSimpler_Cls****
'a customed class
Sub Class_Globals
Private mDrawer As B4XDrawer
Private mCallback As Object
Private mUniWidth As Int=100dip' widths of all leftPanels
Private mLayoutName_Left="LeftPanelLayout" As String 'Layout name of left panels
End Sub
Public Sub Initialize(Callback As Object,parent As B4XView,CenterLayout As String)
mCallback=Callback
mDrawer.Initialize(mCallback,"Drawer",parent,mUniWidth)
mDrawer.CenterPanel.LoadLayout(CenterLayout)
mDrawer.LeftPanel.LoadLayout(mLayoutName_Left)
End Sub
public Sub getActualDrawer As B4XDrawer
Return mDrawer
End Sub
****B4XMainPage*****
Sub Class_Globals
Private Root As B4XView
Private xui As XUI
Private drawer1 As xDrawerSimpler_Cls
Private Button4 As B4XView
Private p2 As Page2
End Sub
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
p2.initialize
drawer1.Initialize(Me,Root,"MainPage")
B4XPages.AddPage("p2",p2)
End Sub
Private Sub Button4_Click 'This event doesn't fire.
B4XPages.ShowPage("p2")
End Sub