Shikhar13 / codenameone

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

longPointerPress is not called for buttons in ListCellRenderer #276

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
When using a button in a ListCellRenderer, the longPointerPress is not called. 
Using Simulator, latest trunk. 

Code example below. 

What is the expected output? What do you see instead?
When pressing and holding the pointer (mouse) on the button, nothing happens. I 
expect to see "Button: longPointerPress(x, y)". 

A short click on the button activates actionPerformed as expected. 

What version of the product are you using? On what operating system?
Latest. Latest Netbeans plugin. Win7.

Please provide any additional information below.

//test code:
final List listx = new List(new DefaultListModel(new String[]{"test1", 
"test2"}));
final Button buttn = new Button(new Command("listenButton") {

    public void actionPerformed(ActionEvent evt) {
        System.out.println("Button command: actionPerformed("+evt+")");
    }
}) {

    protected void longPointerPress(int x, int y) {
        super.longPointerPress(x, y);
        System.out.println("Button: longPointerPress((" + x + ", " + y + ")");
    }
};

listx.setRenderer(new ListCellRenderer() {

    public Component getListCellRendererComponent(List list, Object value, int index, boolean isSelected) {
        buttn.setText("[But-" + (String) value + "]");
        return buttn;
    }

    public Component getListFocusComponent(List list) {
        return new Label();
    }
});

Dialog.show("list", listx, new Command[]{new Command("OK")});

Original issue reported on code.google.com by ch.hj...@gmail.com on 26 Jul 2012 at 6:42

GoogleCodeExporter commented 9 years ago
I'm not sure if this is fixable since we have a "special case" for the pointer 
events in the renderer. 

Original comment by shai.almog on 26 Jul 2012 at 7:25

GoogleCodeExporter commented 9 years ago
fixed, thanks

Original comment by cf27...@gmail.com on 6 Aug 2012 at 12:43

GoogleCodeExporter commented 9 years ago
It works. Excellent - much more than I hoped for, thanks a lot. Any chance 
you'll get around to fixing issue 258 (also linked to renderers) as well? That 
one is actually more blocking for my use than this one was.

Original comment by ch.hj...@gmail.com on 7 Aug 2012 at 4:04