Change font on overflow commad

21 views
Skip to first unread message

Bryan Buchanan

unread,
Jul 5, 2016, 5:39:08 PM7/5/16
to CodenameOne Discussions
If add overflow commands with something like

        f.getToolbar().addMaterialCommandToOverflowMenu("View Cart", FontImage.MATERIAL_SHOPPING_CART, new Command("") {

           
@Override
           
public void actionPerformed(ActionEvent evt) {
               
// do something
           
}
       
});

How can I programatically get the button/label that shows "View Cart" so I can change the font (by user choice, so don't want to set it in the theme).

Shai Almog

unread,
Jul 6, 2016, 1:33:03 AM7/6/16
to CodenameOne Discussions
Use:

Command cmd = f.getToolbar().addMaterialCommandToOverflowMenu(....
Button cmp = f.getToolbar().findCommandComponent(cmd);


Bryan Buchanan

unread,
Jul 6, 2016, 2:08:46 AM7/6/16
to CodenameOne Discussions
I tried that an get a null pointer:

public void addOverflowMenuCommands(final BJBForm f) {

       
Command c = f.getToolbar().addMaterialCommandToOverflowMenu("View Cart", FontImage.MATERIAL_SHOPPING_CART, (ActionListener) (ActionEvent evt) -> {
           
ViewCartForm viewcart = new ViewCartForm().init();
            viewcart
.setBackForm(f);
            viewcart
.show();
       
});
       
Button b = f.getToolbar().findCommandComponent(c);
       
if(b == null) System.err.println("eek");
.....

Shai Almog

unread,
Jul 7, 2016, 12:09:03 AM7/7/16
to CodenameOne Discussions
I didn't get that this is an overflow... The findCommandComponent works for everything except for overflow which is implemented as a List so it has no pre-existing component.

I'm not a fan of that approach but it has some deep roots in our code. You should be able to call setMenuCellRenderer on the toolbar but I'm not really sure...
Reply all
Reply to author
Forward
0 new messages