putClientProperty("SideComponent",...) does not work - codenameone

I have been using the following code to add a CheckBox as a side menu item (see below). But after I update my CodenameOne, Eclipse, and Java versions, this code does not work anymore (side menu does not show the checkbox with label "CheckBox", instead it shows a default side menu item with label "Command").
Should I use a different method to add a component to side menu?
public class SideMenuCheck extends Form{
public SideMenuCheck (){
Toolbar myToolbar=new Toolbar();
setToolbar(myToolbar);
Command sideMenuItemCmd = new Command("Command");
CheckBox sideMenuChkBox = new CheckBox("CheckBox");
sideMenuItemCmd.putClientProperty("SideComponent",sideMenuChkBox);
myToolbar.addCommandToSideMenu(sideMenuItemCmd);
show();
}
}
I have also tried adding a button instead of a check box as side menu item, but this code also failed to show the button on the side menu...
Thank you in advance for your help!

That approach for adding a component to the side menu has been deprecated for a while. You should use the API addComponentToSideMenu instead.
The reason this stopped working for you is the switch from the underlying SideMenuBar implementation to the new on-top implementation a while back.

Related

AgGridReact - Context menu custom component

I am using React Ag-grid version 25.3.0. I am trying add a context menu with an action on hovering over a menu option. I am able to add a contextMenu following the example from here. But we don't have any callback available for hover action. Neither does the context menu(MenuItemDef) accept a JSX component as a menu option to add listeners.
Hence, would like to know if there are other options to add a custom component to the options.
Thanks in advance :)

Codename One nested Sidemenu

I am trying to create a nested side menu for a CN1 application, similar to the one in the screenshot.
For the nested sidemenu to work, I image it has to stay open when the user presses a command of a dropdown list , so that he/ she can choose an option.
But the CN1 sidemenu appears to close every time and I couldn't find a workaround.
One approach I was trying was to add an action event to the "hamburger menu ", but this doesn't seem to work.
Button sideBtn = (Button)((BorderLayout)bar.getLayout()).getEast();
sideBtn.addActionListener(new ActionListener(){
#Override
public void actionPerformed(ActionEvent evt) {
Toolbar.setPermanentSideMenu(true);
};
Neither does adding Toolbar.setPermanentSideMenu(true) to any other button's action event.
Anther approach I have in mind is to add hidden buttons to the sidemenu and repaint the toolbar when the button is clicked, but this still does not keep the sidemenu open and seems to be not very direct.
Is there anything more straightforward? What would be the best approach?
Thanks in advance for any kind response.
The setPermanentSideMenu method is designed for tablets and not for what you are trying to do. Toggling it after the init(Object) method was invoked doesn't make sense and might break your app.
You didn't list how you added the button to the side menu but adding it using addComponentToSideMenu(Component) should work (notice I didn't use the version that accepts a Command).

How to collapse a codename one accordion component programmatically?

How to collapse a codename one accordion component programmatically?
In my App, I have an accordion that expands a body container with some radio buttons. I want to collapse (Close) the body automatically when a radio button is selected.
Adding more details about the problem:
My intention is create a component that has same behavior of a ComboBox, but using Accodion component as base class.
I wrote a minimal use case that reproduce the problem and you can get its source file here MyApplication.java.This code implements Steve Hanna answer.I suppose. And it didn't work for me. Running this code is simple.
Just create a CodeName One project and replace the MyApplication.java file generated by CodeName One Wizard and run the project (I use Netbeans IDE).
I put inside Radio Button action the command to collapse the component as you can see at lines 271 til 280. But it didn't work.
In the radio button's action listener, check if it's not selected and then call collapse(bodyContainer) on the accordion.
EDIT: There was a bug in Accordion that caused collapse() to work incorrectly. This has now been fixed, and will be available in the next plugin update.
See this sample to see correct usage.
Note that after calling collapse(component), you should call the Accordion's animateLayout() method so that the change is shown.

How to show sub menu in Ext Js?

I have a scenario where i have splitbutton which i am able to expand using showMenu function.
var comp = Ext.getCmp('Submenu1');
comp.showMenu();
The menu thus opened has another submenu. I tried using the same showMenu function to expand it, but it didn't work. Do we have some function like showMenu for menuitems in extjs?
Properties of MenuItem
Yes, of course, otherwise ExtJS couldn't open the menu as well...
they didn't make the function part of their public API, but this doesn't mean you can't use it. (they may change the behaviour without notice in updates - but if you don't read every line of their release notes carefully, you won't feel the difference...)
In ExtJS, menu items are of xtype menuitem, which has a doExpandMenu function.
I made this fiddle for you.
I have used following snippet to expand the sub menu item.Just before doExpandMenu i had to activate the element.
window.c = Ext.getCmp('TabBar:AdminTab');
c.showMenu();
c = Ext.getCmp('TabBar:AdminTab:Admin_UsersAndSecurity');
c.activate()
c.doExpandMenu();
c.deactivate();

Why hover to element and click submenu does not work when browser is opened full screen?

I am working on a page where a left hand main menu has submenus. I try to hover to the main menu item, and it will show the submenu, and then I will click the submenu.
I am using below code:
#FindBy(id = "xxx")
private WebElementFacade mainmenu;
#FindBy(id = "yyy")
private WebElementFacade submenu;
Actions builder = new Actions(getDriver());
builder.moveToElement(mainmenu).perform();
submenu.waitUntilClickable().click();
I've tried other ways like:
action.moveToElement(mainmenu).moveToElement(submenu).click().build().perform();
It seems the problem is: when the test is performed when browser is in full screen, i.e.
driver.manage().window().maximize();
the main menu sometimes flash very quickly as if it's clicked really fast and recede, other times it appears not clicked or hovered to at all.
Because this hover and click active happens immediately after user navigate to the page, I add wait for element on the main menu, but it does not seem to work.
Any ideas how to solve the problem? I do not understand why it happens only when browser is in full screen mode. The only reason I can think of is the main menu element need more time to load.
EDIT:
Btw, the issue is very severe in Chrome. Firefox is better, but not 100% working either. It seems that even a simple hover:
mainmenu.waitUntilPresent();
Actions builder = new Actions(getDriver());
builder.moveToElement(mainmenu)perform();
does not always make the main menu display its submenu. I do not understand why it does not work.

Resources