mkvidyashankar Active Member Licensed User Longtime User May 19, 2011 #1 I tried to intercept Back button it works but at the end it exits the app. How to avoid this:sign0085: Sub Activity_KeyPress (KeyCode As Int) As Boolean 'return true if you want to consume the event Dim KC As Boolean If KeyCode = 4 Then KC = True If KC=True Then panel2.Visible=False panel1.Visible=True End If End Sub
I tried to intercept Back button it works but at the end it exits the app. How to avoid this:sign0085: Sub Activity_KeyPress (KeyCode As Int) As Boolean 'return true if you want to consume the event Dim KC As Boolean If KeyCode = 4 Then KC = True If KC=True Then panel2.Visible=False panel1.Visible=True End If End Sub
K kickaha Well-Known Member Licensed User Longtime User May 19, 2011 #2 mkvidyashankar said: I tried to intercept Back button it works but at the end it exits the app. How to avoid this:sign0085: Sub Activity_KeyPress (KeyCode As Int) As Boolean 'return true if you want to consume the event Dim KC As Boolean If KeyCode = 4 Then KC = True If KC=True Then panel2.Visible=False panel1.Visible=True End If End Sub Click to expand... The clue is in the comment: Sub Activity_KeyPress (KeyCode As Int) As Boolean 'return true if you want to consume the event Before your (second) End If you need to add: Return True This stops the OS from dealing with the keypress, so the app will not stop. BTW, your code would be much neater as: Code: Sub Activity_KeyPress (KeyCode As Int) As Boolean 'return true if you want to consume the event If KeyCode = 4 Then panel2.Visible=False panel1.Visible=True Return True End If End Sub As KC is not really needed. Upvote 0
mkvidyashankar said: I tried to intercept Back button it works but at the end it exits the app. How to avoid this:sign0085: Sub Activity_KeyPress (KeyCode As Int) As Boolean 'return true if you want to consume the event Dim KC As Boolean If KeyCode = 4 Then KC = True If KC=True Then panel2.Visible=False panel1.Visible=True End If End Sub Click to expand... The clue is in the comment: Sub Activity_KeyPress (KeyCode As Int) As Boolean 'return true if you want to consume the event Before your (second) End If you need to add: Return True This stops the OS from dealing with the keypress, so the app will not stop. BTW, your code would be much neater as: Code: Sub Activity_KeyPress (KeyCode As Int) As Boolean 'return true if you want to consume the event If KeyCode = 4 Then panel2.Visible=False panel1.Visible=True Return True End If End Sub As KC is not really needed.
mkvidyashankar Active Member Licensed User Longtime User May 19, 2011 #3 Thanks kickaha for Quick reply its working Upvote 0