Focus Issue - EditText

joshb86

New Member
I searched and couldn't find any solution to this... Plus I'm not sure if it's just limited to the Trial version since that is what I'm currently playing with, so didn't want to put this in the bug section.

I have a simple activity with an EditText and a ListView. When the editText_EnterPressed method triggers, it simply adds the entered text to the listview. The problem is the EditText then loses focus and requesting focus doesn't work. I even monitored it with the FocusChanged sub which if HasFocus was false, it would request focus. Odd part is when I did this, the focus appeared to actually be set... but no matter how much you type, the EditText no longer accept text.

Anyone seen this?
 

joshb86

New Member
I haven't encountered such issue. Can you upload your project?


Thanks Erel! Here is the download link. Run as is first to see it lose focus, un-comment the HasFocus line and you'll see the issue I'm having where it keeps focus but no longer accepts any text even after pressing again. I might be locking it up somehow... Thanks for taking a look.

Not allowed to post url's yet... maybe this tricks it.
"http://sbreach.info/test.rar"
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Note that you can upload attachments directly to the forum. Use File - Export As Zip and it will create a zip file containing the required files.

It is possible that requesting the focus inside the FocusChanges event will confuse the native focus mechanism. You can try using a timer with a short interval that will set the focus and disable itself.
You should enable the timer in the EnterPressed sub.
 
Upvote 0

joshb86

New Member


Thanks I'll give this a shot. I'm a but curious at what causes the EditText to lose focus. Doing this same thing in java/eclipse the EditText being the only input control always keeps focus. No worries though, I'm fine with using the timer trick.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…