2 panels not working right

slydog43

Member
Licensed User
Longtime User
I made a very simple sample program that demonstrates my problem. Basically you tap the 1st screen "login" button which initializes a panel and shows it. If you tap between the 2 buttons on the login screen (where the login button is on the 1st screen) something gets messed up. Doesnt fire any events, but messes up the program. I see that GC gets run when you tap between the 2 buttons, any ideas?





'Activity module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.

End Sub

Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.

Dim pnlLogin As Panel

Dim MainMenu_Button_Login As Button
Dim Login_Button_Accept As Button
Dim Login_Button_Cancel As Button
End Sub

Sub Activity_Create(FirstTime As Boolean)

Activity.LoadLayout("LayoutMainMenu")
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub


Sub MainMenu_Button_Login_Click

pnlLogin.Initialize("")
Activity.AddView(pnlLogin, 0, 0, 100%x, 100%y)
pnlLogin.LoadLayout("LayoutLogin")

End Sub
Sub Login_Button_Cancel_Click

pnlLogin.RemoveView

End Sub
Sub Login_Button_Accept_Click

pnlLogin.RemoveView
End Sub
:BangHead:
 

Attachments

  • panels.zip
    6.2 KB · Views: 246
Last edited:

slydog43

Member
Licensed User
Longtime User
I have seen some other threads about this, it seems that the previous panel still gets button taps even after I show the second one which is full screen. My demo app clearly shows this. I guess I have to implement my own push/pop panel routine?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
The solution is quite simple. In order to debug it I've added some Log messages which helped me see the problem.

You are not catching the panel's click event. Then when the user clicks between the two buttons the main button catches this event and creates a new panel. The point is that even when the button is hidden by the panel it can catch the click event if no other view catches it (this is handled by Android OS).

The solution is to catch the panel click event:
B4X:
Sub MainMenu_Button_Login_Click
    Log("1")
    pnlLogin.Initialize("pnlLogin")
     Activity.AddView(pnlLogin, 0, 0, 100%x, 100%y)
     pnlLogin.LoadLayout("LayoutLogin")
    pnlLogin.Color = Colors.Green
End Sub
Sub Login_Button_Cancel_Click
    Log("2")
    pnlLogin.RemoveView        
End Sub
Sub Login_Button_Accept_Click
    Log("3")
    pnlLogin.RemoveView    
End Sub
Sub pnlLogin_Click

End Sub
 

slydog43

Member
Licensed User
Longtime User
wow what great support, but I have tried that. I cut and pasted your stuff and it WORKED, AWESOME!!


I found out what it was,

pnlLogin.Initialize("")

should have been pnlLogin.Initialize("pnlLogin")

along with adding the pnlLogin_Click
THANKS


STEVE
 
Last edited:
Top