PDA

View Full Version : GXT 2.0.1 CheckMenuItem problem



aurelie
3 Aug 2009, 2:04 AM
Hi,

My checkMenuItems don't work.
I have download the Samples, and in the "Basic ToolBar" Sample, thay don't work too.
When you click on a checkMenuItem, nothing changes. it doesn't become checked.

sven
3 Aug 2009, 2:05 AM
http://www.extjs.com/examples/explorer.html#basictoolbar

Try it out if it is working on the demos for you.

aurelie
3 Aug 2009, 4:02 AM
on the website, it works but when i download samples and i try to use it with GWT, it doesn't work.
if I add a SelectionListener and I asked if my case is checked, it appears it's checked.
But it doesn't appear visually

Arno.Nyhm
6 Aug 2009, 4:56 AM
maybe there is some bug in your code. can you post a working sample that we can replay your code.

babyblue
10 Aug 2009, 10:30 AM
Did this get resolved? I'm experiencing the same problem. I don't think I saw this in earlier RC releases. Here is my code:


package com.example.client;

import com.extjs.gxt.ui.client.event.MenuEvent;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.widget.Component;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.extjs.gxt.ui.client.widget.menu.CheckMenuItem;
import com.extjs.gxt.ui.client.widget.menu.Menu;
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.RootPanel;

public class Test implements EntryPoint {

public void onModuleLoad() {
Window.enableScrolling(false); // force hide scroll bar
RootPanel.get("toolbar").add(createToolbar());
RootPanel.get("main").add(createPanel());
}

private LayoutContainer createToolbar() {
ToolBar toolbar = new ToolBar();
toolbar.add(createCheckboxMenu());
toolbar.add(createRadioMenu());

LayoutContainer parent = new LayoutContainer();
parent.add(toolbar);
return parent;
}

private Button createRadioMenu() {
final Menu menu = new Menu();

CheckMenuItem menuItem = new CheckMenuItem("Option A");
menuItem.setGroup("group");
menuItem.setChecked(true);
menu.add(menuItem);

menuItem = new CheckMenuItem("Option B");
menuItem.setGroup("group");
menuItem.setChecked(false);
menu.add(menuItem);

Button menuButton = new Button("Button w/ Radio Options");
menuButton.setMenu(menu);

return menuButton;
}

private Button createCheckboxMenu() {
Menu menu = new Menu();
CheckMenuItem menuItem = new CheckMenuItem("I Like Cats");
menuItem.setChecked(true);
menuItem.addSelectionListener(new SelectionListener<MenuEvent>(){
@Override
public void componentSelected(MenuEvent ce){
CheckMenuItem selected = (CheckMenuItem)ce.getItem();
// need this to update the checkbox icon
selected.setText(selected.getText());
}

});
menu.add(menuItem);

Button menuButton = new Button("Button w/ Checkboxes");
menuButton.setMenu(menu);
return menuButton;
}

private LayoutContainer createPanel() {
LayoutContainer c = new LayoutContainer();
return c;
}
}

babyblue
10 Aug 2009, 10:36 AM
Looks like this is same problem as the checkbox type item, https://extjs.com/forum/showthread.php?p=358880. Using the same fix (though more annoying) seem to resolve the problem. I added following listener to every radio item:



SelectionListener<MenuEvent> listener = new SelectionListener<MenuEvent>(){
@Override
public void componentSelected(MenuEvent ce){
int total = menu.getItemCount();
for(int i = 0; i < total; i++) {
CheckMenuItem item = (CheckMenuItem)menu.getItem(i);
item.setText(item.getText());
}
}
};

Arno.Nyhm
11 Aug 2009, 12:04 AM
@babyblue:

i try out your example, and it works also without the listeners with the "item.setText(item.getText());" hack on both menu items in this environment:

- Hosted Mode (Debug)
- FF 3.0
- Chrome 2.0
- IE 7.0

GWT 1.7 / GXT 2.0.1
Windows XP

Arno.Nyhm
11 Aug 2009, 12:06 AM
maybe you need check that you on GXT2.0.1 also with the css stuff. (just a guess)

babyblue
11 Aug 2009, 9:56 AM
I'm on XP as well but I have IE6 in Hosted mode. This would explain why the demo works fine (I tried firefox and chrome), but my code does not (first test in the Hosted mode). So looks like only issue with IE6.