Back button doubles toolbar dimension

18 views
Skip to first unread message

P5music

unread,
Aug 16, 2020, 1:47:47 PM8/16/20
to CodenameOne Discussions
I added the back functionality to forms that call one another
A->B->C

I put a button on the toolbar, otherwise the back command is not visible.

Button backButton=new Button("back");
Command backCommand=new Command("Back") {
   
@Override
    public void actionPerformed(ActionEvent evt) {
       
mainForm.showBack();
   
}
};

backButton.setCommand(backCommand);
getToolbar
().add(BorderLayout.WEST,backButton);

but the result is a doubled toolbar, as you can see in the attached image.
And you can also see that the message is "Back", not "back".
So it's not the Button displayed there, but if I do not add it, nothing is displayed. It's strange.
What's wrong?
Thanks in advance

2020-08-16 19-40-21.png

Shai Almog

unread,
Aug 16, 2020, 9:43:26 PM8/16/20
to CodenameOne Discussions
Use toolbar.setBackCommand(). Or toolbar.addMaterialCommand* methods etc.

P5music

unread,
Aug 17, 2020, 5:10:18 AM8/17/20
to CodenameOne Discussions
With only this code too I get the double-sized toolbar, as you can see in the attached image.

Command backCommand=new Command("Back") {
@Override
public void actionPerformed(ActionEvent evt) {
        parentForm.showBack();
}
};

getToolbar().setBackCommand(backCommand);
2020-08-17 11-09-22.png

Shai Almog

unread,
Aug 17, 2020, 9:49:50 PM8/17/20
to CodenameOne Discussions
Is this on iOS. I think your referring to the StatusBar. On iOS you need to render the area where the time/clock etc. are drawn. Where the notch will hide your title anyway. So we have an implicit padding called StatusBar. on the top of the UI.
Reply all
Reply to author
Forward
0 new messages