Display Issue in Simulator With TextComponent

18 views
Skip to first unread message

Pablo Vadear

unread,
Apr 20, 2018, 10:24:05 PM4/20/18
to CodenameOne Discussions
I'm using Intellij IDEA.  When run in the simulator the behavior of the text component in the following code is not correct.  The hint does not move into the label position when the form loads.  The label position remains blank until the field loses focus and then regains focus the second time.  On the second and subsequent focus event the label functions as expected.

However, if I comment out either the button being added to the container or the setEditOnShow() line then it works correctly.  I'm presuming I'm doing something wrong here because it seems to work fine on an Android device. Btw, this is cut from a much larger form just to reproduce the issue.  I thought perhaps the TextModeLayout was causing the problem with adding the button but even if I move the button outside of the container to BorderLayout.SOUTH the same issue persists.  What am I doing wrong? 

private void showTestForm(Form parent) {

   
Form f = new Form("Edit Entry", new BorderLayout());
    f
.getToolbar().setBackCommand("Back", e -> parent.showBack());

   
TextModeLayout layout = new TextModeLayout(2, 1);
   
Container c = new Container(layout);

   
TextComponent meetingName = new TextComponent().labelAndHint("Meeting Name");
    c
.add(layout.createConstraint().widthPercentage(100), meetingName);

   
Button saveButton = new Button("Save List");
    c
.add(layout.createConstraint().widthPercentage(100), saveButton);

    f
.add(BorderLayout.CENTER, c);
    f
.setEditOnShow(meetingName.getField());
    f
.show();

}
Enter code here...


Paul Wade

unread,
Apr 20, 2018, 10:29:17 PM4/20/18
to CodenameOne Discussions
Attached an screenshot of how the selected field looks when the form loads initially.  The cursor isn't visible but it's in the first field.
broken_label.jpg

Paul Wade

unread,
Apr 20, 2018, 10:32:45 PM4/20/18
to CodenameOne Discussions
So, no way to edit a post?  That's fun.  Anyway, wanted to clarify that in the screenshot I added a second field not shown in the sample code just so I could change focus more easily.  It's irrelevant really but didn't want someone to get hung up on it.

Shai Almog

unread,
Apr 21, 2018, 12:45:18 AM4/21/18
to CodenameOne Discussions
I see the problem. Your code looks fine although I would add a c.setScrollableY(true) to the code but that doesn't seem to make a difference.

Can you file an issue? We'll try to track it down.

http://github.com/codenameone/CodenameOne/issues/new

Paul Wade

unread,
Apr 21, 2018, 2:35:33 AM4/21/18
to CodenameOne Discussions
Thanks and done!
Reply all
Reply to author
Forward
0 new messages