How can I get rid of an empty side menu that shows up when I use the toolbar API?

27 views
Skip to first unread message

sidiabale

unread,
Sep 21, 2015, 12:02:16 PM9/21/15
to CodenameOne Discussions
Hi,

I have a GUI builder project in which I apply the toolbar to only one form. I add a custom title component and a command to the right. However, I see an unexpected side (hamburger) menu with no commands as illustrated in the attached photos. How can I get rid of the side menu?

Here's the relevant code:

        final Toolbar toolbar = new Toolbar();
        f.setToolBar(toolbar);
                
        final Container titleComponent = new Container(new BorderLayout());
        final String titleText = contactToShow.getFirstName().toUpperCase().charAt(0) + ". " + contactToShow.getSurname();
        final Label titleLabel = new Label(titleText);
        titleLabel.setUIID("Title");
        
        final String counterText = String.valueOf(contactAdapter.getContactIndex(contactToShow) + 1)
                + "/" + String.valueOf(contactAdapter.getContactCount());
        
        titleComponent.addComponent(BorderLayout.CENTER, titleLabel);
        titleComponent.addComponent(BorderLayout.EAST, new Label(counterText));
        toolbar.setTitleComponent(titleComponent);
                
        final Command backCommand = new Command("Contacts") {
            
            @Override
            public void actionPerformed(ActionEvent evt) {
                back();
            }
        };
        
        toolbar.addCommandToLeftBar(backCommand);



If you are experiencing an issue please mention the full platform your issue applies to:
IDE: NetBeans/Eclipse/IDEA
Desktop OS
Simulator
Device

Shai Almog

unread,
Sep 22, 2015, 12:08:55 AM9/22/15
to CodenameOne Discussions
Hi,
try this in the state machine and see if it solves your issue:
    protected void setBackCommand(Form f, Command backCommand) {
       
if(f.getName().equals("ProblematicFormName")) {
           
return;
       
}
       
super.setBackCommand(f, backButton);
   
}


sidiabale

unread,
Sep 22, 2015, 12:19:49 PM9/22/15
to CodenameOne Discussions
Hi,

Thanks for the pointer. It didn't solve the problem but helped me find it. It turned out that I was still adding the command to the form directly elsewhere. Everything works fine now.

Cheers
Reply all
Reply to author
Forward
0 new messages