Android text vanishes from textfield when not in focus while keyboard is visible

32 views
Skip to first unread message

Gareth Murfin

unread,
Mar 2, 2016, 8:24:59 AM3/2/16
to CodenameOne Discussions
My client just noticed that when the textfields in our app are not in focus and the user taps outside of the keyboard while it is showing (on Android) the text vanishes completely, I looked at the unselected state and it should have a proper text colour, the text is not even white or black it is simply gone, almost as if it is not painting in that circumstance, anyone else noticed this? 

Gareth Murfin

unread,
Mar 2, 2016, 8:27:54 AM3/2/16
to CodenameOne Discussions
Whoops that was confusing, steps to recreate, make a textfield, run app, tap textfield, type some text, keep the keyboard visible and tap somewhere else on your form other than the textfield. Observe text vanishes from textfield, this does not happen in standard android. 

Steve CN1 Hannah

unread,
Mar 2, 2016, 10:48:55 AM3/2/16
to codenameone...@googlegroups.com
Thanks.  This was a regression from some recent changes.  It is fixed now in Git and should be on the server soon.

Steve

--
You received this message because you are subscribed to the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to codenameone-discu...@googlegroups.com.
Visit this group at https://groups.google.com/group/codenameone-discussions.
To view this discussion on the web visit https://groups.google.com/d/msgid/codenameone-discussions/79f99775-d2a4-4257-bcbf-656d69b626f7%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Steve Hannah
Software Developer
Codename One

Gareth Murfin

unread,
Mar 2, 2016, 6:19:30 PM3/2/16
to CodenameOne Discussions
Thanks Steve, what a quick fix!


On Wednesday, March 2, 2016 at 11:48:55 PM UTC+8, Steve CN1 Hannah wrote:
Thanks.  This was a regression from some recent changes.  It is fixed now in Git and should be on the server soon.

Steve
On Wed, Mar 2, 2016 at 5:27 AM, Gareth Murfin <gareth...@gmail.com> wrote:
Whoops that was confusing, steps to recreate, make a textfield, run app, tap textfield, type some text, keep the keyboard visible and tap somewhere else on your form other than the textfield. Observe text vanishes from textfield, this does not happen in standard android. 

On Wednesday, March 2, 2016 at 9:24:59 PM UTC+8, Gareth Murfin wrote:
My client just noticed that when the textfields in our app are not in focus and the user taps outside of the keyboard while it is showing (on Android) the text vanishes completely, I looked at the unselected state and it should have a proper text colour, the text is not even white or black it is simply gone, almost as if it is not painting in that circumstance, anyone else noticed this? 

--
You received this message because you are subscribed to the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to codenameone-discussions+unsub...@googlegroups.com.

Nicola Dell'Amico

unread,
Feb 26, 2018, 12:17:48 AM2/26/18
to CodenameOne Discussions
Hi, I'm developing an application for Android 4.1.1 on Linux with Netbeans and CodeNameOne plugin rev.3.8.0 and still having that issue (working fine on latest android OS , but I have tio run the on rugggerized industrial device and have no optiont to upgrade the OS).
Wasn't it fixed ?
I tried anything but no luck.

Please help !!!!!!



On Wednesday, March 2, 2016 at 4:48:55 PM UTC+1, Steve Hannah wrote:
Thanks.  This was a regression from some recent changes.  It is fixed now in Git and should be on the server soon.

Steve
On Wed, Mar 2, 2016 at 5:27 AM, Gareth Murfin <gareth...@gmail.com> wrote:
Whoops that was confusing, steps to recreate, make a textfield, run app, tap textfield, type some text, keep the keyboard visible and tap somewhere else on your form other than the textfield. Observe text vanishes from textfield, this does not happen in standard android. 

On Wednesday, March 2, 2016 at 9:24:59 PM UTC+8, Gareth Murfin wrote:
My client just noticed that when the textfields in our app are not in focus and the user taps outside of the keyboard while it is showing (on Android) the text vanishes completely, I looked at the unselected state and it should have a proper text colour, the text is not even white or black it is simply gone, almost as if it is not painting in that circumstance, anyone else noticed this? 

--
You received this message because you are subscribed to the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to codenameone-discussions+unsub...@googlegroups.com.

Nicola Dell'Amico

unread,
Feb 26, 2018, 12:38:55 AM2/26/18
to CodenameOne Discussions

Further ,
I tried with:
        TextField.setUseNativeTextInput(false);
Now only the new edited text disappears and the TextField only shows the original text.
From TextField src code code I found:
    public void paint(Graphics g) {
       
       
//the native input will show the string.
       
if(useNativeTextInput && Display.getInstance().isNativeEditorVisible(this)) {
           
return;
       
}

       
UIManager manager = getUIManager();
        manager
.getLookAndFeel().drawTextField(g, this);
       
       
if (drawCursor && hasFocus() && isEditable()) {
            manager
.getLookAndFeel().drawTextFieldCursor(g, this);
       
}
       
        paintHint
(g);
   
}


Whats' wrong ?

Steve Hannah

unread,
Feb 26, 2018, 7:37:53 AM2/26/18
to codenameone...@googlegroups.com
This issue has been elusive to detect.  See comment here 

It is scheduled for 5.0 unless some major breakthrough occurs.

You can workaround it in the meantime by adding the following to your text field:
textField.putClientProperty("android.cursorVisible", Boolean.FALSE)

This disables the blinking cursor in the field, which strangely fixes the issue of disappearing text in some (not all) older versions of android.

Steve

To unsubscribe from this group and stop receiving emails from it, send an email to codenameone-discussions+unsubscr...@googlegroups.com.



--
Steve Hannah
Software Developer
Codename One

--
You received this message because you are subscribed to the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to codenameone-discussions+unsub...@googlegroups.com.
Visit this group at https://groups.google.com/group/codenameone-discussions.

For more options, visit https://groups.google.com/d/optout.

Nicola Dell'Amico

unread,
Feb 26, 2018, 9:18:37 AM2/26/18
to CodenameOne Discussions
Hi Steve,
thank you very much for the support and quick reply.

I Tried your solution and that works, but the cursor is totally invisible and user cannot get the position in the text where he is editing.
It would be nice to have fixed (not blinking) cursor at the edit position ....
I tried setting the blinking cusor on and off time to a large value and 0 respectively, but the I saw that applies on if native input not used

Why if I disable nativeInput I got odd text in the edit ? Is it another bug ?

What about subclass the TextView and override the significant methods to patch ? Any hints about that ?

Thanks
Nicola
To unsubscribe from this group and stop receiving emails from it, send an email to codenameone-discussions+unsub...@googlegroups.com.
Visit this group at https://groups.google.com/group/codenameone-discussions.



--
Steve Hannah
Software Developer
Codename One

--
You received this message because you are subscribed to the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to codenameone-discussions+unsub...@googlegroups.com.
Visit this group at https://groups.google.com/group/codenameone-discussions.
To view this discussion on the web visit https://groups.google.com/d/msgid/codenameone-discussions/cbddd504-7499-483b-9ac2-b40e638142bb%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages