Shikhar13 / codenameone

Automatically exported from code.google.com/p/codenameone
0 stars 0 forks source link

Clicking in CellRenderer does not work for ContainerList (but works in ListCellRenderer for List) #258

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The example below does not work with a ContainerList and using CellRenderer. 
When you click in one of there rendered elements, the actionPerformed is not 
triggered. 

The same example works as expected when replacing ContainerList with List, and 
CellRenderer with ListCellRenderer. 
http://codenameone.blogspot.dk/2011/05/clicking-within-cell-renderer.html

final ContainerList clist = new ContainerList(new DefaultListModel(new 
String[]{"test1", "test2"}));
final Button button = new Button(new Command("listenButton") {

    public void actionPerformed(ActionEvent evt) {
        System.out.println("getSelectedItem()=" + clist.getSelectedItem());
    }
});
final Container container = new Container();
container.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
container.addComponent(button);

clist.setRenderer(new CellRenderer() {

    public Component getCellRendererComponent(Component list, Object model, Object value, int index, boolean isSelected) {
        button.setText("[Button-" + (String) value + "]");
        return container;
    }

    public Component getFocusComponent(Component list) {
        return new Label();
    }
});
Dialog.show("list", clist, new Command[]{new Command("OK")});

What version of the product are you using? On what operating system?
latest trunk (as of July 11th 2012)

Please provide any additional information below.

Original issue reported on code.google.com by ch.hj...@gmail.com on 13 Jul 2012 at 8:55

GoogleCodeExporter commented 9 years ago
I committed an attempt at fixing this.

Original comment by shai.almog on 13 Jul 2012 at 4:09

GoogleCodeExporter commented 9 years ago
Tried recompiling the example on latest trunk, but it still doesn't work. 

Original comment by ch.hj...@gmail.com on 26 Jul 2012 at 6:31

GoogleCodeExporter commented 9 years ago
I'll take another look.

Original comment by shai.almog on 27 Jul 2012 at 7:17

GoogleCodeExporter commented 9 years ago
I just downloaded the latest trunk two days ago, but the example above still 
doesn't work. Did you try your fix on the code I included? It's a pretty 
annoying difference between normal List and ContainerList that basically 
prevents me from using the ContainerList. 

Original comment by ch.hj...@gmail.com on 2 Aug 2012 at 9:25

GoogleCodeExporter commented 9 years ago
I didn't get a chance to fix it yet. You can track our changes in the SVN 
changeset.

Original comment by shai.almog on 3 Aug 2012 at 8:08

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r385.

Original comment by cf27...@gmail.com on 8 Aug 2012 at 10:31

GoogleCodeExporter commented 9 years ago
fixed, thanks

Original comment by cf27...@gmail.com on 8 Aug 2012 at 10:32

GoogleCodeExporter commented 9 years ago
Thanks for looking at this. I just fetched and recompiled r385, but the above 
example still doesn't work for me?

Original comment by ch.hj...@gmail.com on 8 Aug 2012 at 3:28

GoogleCodeExporter commented 9 years ago

Original comment by shai.almog on 8 Aug 2012 at 3:55

GoogleCodeExporter commented 9 years ago
Sorry! My mistake, there was a merge problem when I downloaded the revision. 
I've corrected it and the fix in r385 works fine, so please close this one. And 
big thanks for fixing it!

Original comment by ch.hj...@gmail.com on 9 Aug 2012 at 5:58

GoogleCodeExporter commented 9 years ago

Original comment by cf27...@gmail.com on 10 Aug 2012 at 7:34