Wish TextField1_FocusChanged(HasFocus As Boolean)

BPak

Active Member
Licensed User
Longtime User
Wish that the TextField had an event for Focus Changed.
 

LucaMs

Expert
Licensed User
Longtime User
It "has" that event.

Declare an EditText in the Globals section.

Then write:

Sub + Space + Tab + e (for edittext) + Tab again. This lists all avalaible events for EditText

P.S. You don't need to declare the EditText, the "procedure" works even without it
 

BPak

Active Member
Licensed User
Longtime User
It "has" that event.

Declare an EditText in the Globals section.

Then write:

Sub + Space + Tab + e (for edittext) + Tab again. This lists all avalaible events for EditText

P.S. You don't need to declare the EditText, the "procedure" works even without it

Does not show any TextField Focus Changed in the list.
See images
textfield1.png
textfield2.png
 

LucaMs

Expert
Licensed User
Longtime User
SORRY !!!

I did not realize that it is a thread B4J.

There is in B4A.

I believe that there is a way, via Reflection.

I guess (hope) that this library exits already in B4J.
 

LucaMs

Expert
Licensed User
Longtime User
I found this example (by Stevel05):

B4X:
    Dim R As Reflector
    R.Target = EditText1
    R.SetOnFocusListener("ETFocus")

Sub ETFocus(ViewTag As Object,Focus As Boolean)
    Log(Focus)
End Sub
 

stevel05

Expert
Licensed User
Longtime User
Unfortunately that example is B4a as well.

It's a different process with B4j which uses change listeners which Andrew has exposed in his jReflection Library.

So on B4j it would be:

B4X:
    Dim R As Reflector
R.Target = TextField1
R.AddChangeListener("TextField1Focus","focusedProperty")
End Sub

Sub TextField1Focus_Changed(old As Object,New As Object)
    Log(New)
End Sub
 
Last edited:

LucaMs

Expert
Licensed User
Longtime User
This is good example of where there is confusion between B4A and B4J.
I still think it would be better to split this Forum in totally separate B4A and B4J sections.
B4J is cluttering the B4A forum, at least that is still my opinion.

No, it is the typical error of my distraction :D
 
Top