H heloman996 New Member Licensed User Longtime User May 29, 2011 #1 1. On my DROID I have the built in "Return, Menu, Home and Search" Icons. How do I detect the android "return" icon click? Thanks, Heloman
1. On my DROID I have the built in "Return, Menu, Home and Search" Icons. How do I detect the android "return" icon click? Thanks, Heloman
I Inman Well-Known Member Licensed User Longtime User May 29, 2011 #2 Return is actually the Back key. This is how you trap the Back key Code: Copy Sub Activity_KeyPress (KeyCode As Int) As Boolean 'return true if you want to consume the event If KeyCode=KeyCodes.KEYCODE_BACK Then 'Give statements to execute when Back key is pressed Return True End If End Sub Upvote 0
Return is actually the Back key. This is how you trap the Back key Code: Copy Sub Activity_KeyPress (KeyCode As Int) As Boolean 'return true if you want to consume the event If KeyCode=KeyCodes.KEYCODE_BACK Then 'Give statements to execute when Back key is pressed Return True End If End Sub
L Libor Member Licensed User Longtime User Jun 13, 2011 #4 Consume, Return, Void questions Inman said: Return is actually the Back key. This is how you trap the Back key Code: Copy Sub Activity_KeyPress (KeyCode As Int) As Boolean 'return true if you want to consume the event If KeyCode=KeyCodes.KEYCODE_BACK Then 'Give statements to execute when Back key is pressed Return True End If End Sub Click to expand... Hi one follow up. What does consume the event actually mean? I've seen this in several postings. I'm just reading through the threads to get an idea what is possible and what is not as well as learn how to use B4A and find this confusing perhaps because I'm not a programmer. Does it mean I just exit the event and go back to where it was called from and since I'm returning true it appears that the event completed? Or am I not understanding this correctly. I see that the following in the help: KEYWORDS Return Method Returns from the current sub and optionally returns the given value. Syntax: Return [value] Returns : Void Unfortunately I don't really understand what that means. I have also seen Void all over the place but not been able to get a clear understanding of what that means. thanks Libor Upvote 0
Consume, Return, Void questions Inman said: Return is actually the Back key. This is how you trap the Back key Code: Copy Sub Activity_KeyPress (KeyCode As Int) As Boolean 'return true if you want to consume the event If KeyCode=KeyCodes.KEYCODE_BACK Then 'Give statements to execute when Back key is pressed Return True End If End Sub Click to expand... Hi one follow up. What does consume the event actually mean? I've seen this in several postings. I'm just reading through the threads to get an idea what is possible and what is not as well as learn how to use B4A and find this confusing perhaps because I'm not a programmer. Does it mean I just exit the event and go back to where it was called from and since I'm returning true it appears that the event completed? Or am I not understanding this correctly. I see that the following in the help: KEYWORDS Return Method Returns from the current sub and optionally returns the given value. Syntax: Return [value] Returns : Void Unfortunately I don't really understand what that means. I have also seen Void all over the place but not been able to get a clear understanding of what that means. thanks Libor
Erel B4X founder Staff member Licensed User Longtime User Jun 14, 2011 #5 The internal Android method that raises this event checks the return value. If it is not True then the key press event will be handled by the system, which will close the current activity. Upvote 0
The internal Android method that raises this event checks the return value. If it is not True then the key press event will be handled by the system, which will close the current activity.
L Libor Member Licensed User Longtime User Jun 14, 2011 #6 Hi Erel, thanks. That actually clears a bit of it up for me and explains why some other functions I created were not working the way I wanted. Upvote 0
Hi Erel, thanks. That actually clears a bit of it up for me and explains why some other functions I created were not working the way I wanted.