Is there a way to add a textfield to the command bar?

27 views
Skip to first unread message

howud...@gmail.com

unread,
Nov 9, 2016, 6:28:03 PM11/9/16
to CodenameOne Discussions
I have a form with a map component.  I want to add a simple search field to the map and dont want to use the entire NORTH section, just a small part between the title and the right command  this.getToolbar().addCommandToRightBar(cmdList);
How can I add a textfield to the toolbar?  I tried:
        Command cmd = new Command("");
        cmd.putClientProperty(SideMenuBar.COMMAND_SIDE_COMPONENT, tfGoogleSearch);
        cmd.putClientProperty(SideMenuBar.COMMAND_ACTIONABLE, Boolean.FALSE);
        cmd.putClientProperty("TitleCommand", Boolean.TRUE);
this.getToolbar().addCommandToRightBar(cmd);


but that didn't work.  I also tried:

        this.getToolbar().addComponentToSideMenu(tfGoogleSearch);



but that put it in the left fly out menu and I want it in the titlebar

Shai Almog

unread,
Nov 9, 2016, 11:48:28 PM11/9/16
to CodenameOne Discussions, howud...@gmail.com

howud...@gmail.com

unread,
Nov 10, 2016, 11:58:35 AM11/10/16
to CodenameOne Discussions, howud...@gmail.com
This is a nice feature and I will use it.   I have three questions:
1.  How can I know if the enter key or search key was pressed?  I dont want to process every single change...remember this is going to be sending requests off to google to plot on the map
2.  After the user presses enter/search on their keyboard and I present the results fro google, how can I hide the searchbar and go back to the normal title bar
3.  What if I dont want to use the search mode and want a textfield in the titlebar for another reason?

Finally this is not a question but a bug.  when activating the search bar in the emulator the keyboard doesn't popup

Peter

Shai Almog

unread,
Nov 11, 2016, 12:32:59 AM11/11/16
to CodenameOne Discussions, howud...@gmail.com
If you want more control over this functionality check out the javadocs for toolbar where there is a sample of implementing this manually.
Reply all
Reply to author
Forward
0 new messages