Android Question Enterpressed for any EditText [Solved]

Roger Daley

Well-Known Member
Licensed User
Longtime User
Hi All,

I have an activity with several EditTexts, I have a sub that is actioned whenever the Enterpressed event occurs on any of the EditTexts.
Instead of writing a Sub to handle each editText is there a way to detect Enterpressed on any EditText.

Regards Roger

IE:
B4X:
'Instead of:
Sub Edt1_EnterPressed
    Action
End Sub

Sub Edt2_EnterPressed
    Action
End Sub

Sub Edt3_EnterPressed
    Action
End Sub  
Etc. Etc. Etc......

'could possibly be:
Sub AnyOldEdt_EnterPressed
    Action
End Sub
 
Last edited:

drgottjr

Expert
Licensed User
Longtime User
didn't i explain this to you in a different thread yesterday? you use the tag property to identify which edittext the user was in when she pressed the enter key...
 
Upvote 0

mangojack

Well-Known Member
Licensed User
Longtime User
Possible solution ...
1. set the tag property of all edittexts .. ie: edt1, edt2
2. set all EditText event names to a common event. ie: EditText

B4X:
Sub EditText_EnterPressed
    Dim edt As EditText = Sender

    Select edt.Tag
        Case "edt1"
            Log ("yipy")
        Case "edt2"
            Log("zipy")
    End Select
End Sub


Edit ... Apologies @drgottjr ... I thought you might be confusing this with OPs question regarding EditText Focus Today but maybe not.
 
Upvote 0

Roger Daley

Well-Known Member
Licensed User
Longtime User
didn't i explain this to you in a different thread yesterday? you use the tag property to identify which edittext the user was in when she pressed the enter key...


No drgottjr, you answered a different question regarding edittexts and focus.

 
Upvote 0

Roger Daley

Well-Known Member
Licensed User
Longtime User


Thanks mangojack,
I must have been having a bad day, I have used this technique in the past to handle keys on a keyboard and of course it works well.

Regards Roger
 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
i believe my answer from that link said, among other things:
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…