Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [nebula-dev] PListItem Listener Help in PaletteShelfStrategy environment

Hi PK,

The item classes don't have any events. Item classes do not typically have low-level events like mouse events, and only sometimes will have higher level events like selection. The PShelf and PList class has the selection events/listeners. You should listen for the selection event on the parent widget, rather then listening for low-level events on the item classes.

-Chris


Prakash Rao Kanthi wrote:
Hi Chris & All,

I am using SWTPlus components in my projects. I have a big problem with 'Listener' for PListItem. The problem is, Listener is never invoked for PListItem. There is no MouseListener for PLIstItem. PShelf and PList have MouseListeners and they work just fine. Following is the code segment. Can you please let me know what i am doing wrong?

Looks like the problem is any listener registered using 'addListener(int eventType, Listener listener)' does seem to work. I tried all SWT event types.

Thanks,
PK

-----------------------------------------------------------------------
PShelfItem si = new PShelfItem(pShelf,SWT.NONE);
si.setText("ShelfIetm1");
si.setImage(GalleryImageRegistry.getImage(this.getClass(),"list4_small.png"));

GridLayout gl = new GridLayout();
gl.marginHeight = 0;
gl.marginWidth = 0;
si.getBody().setLayout(gl);
ListBarListStrategy listStrategy = new ListBarListStrategy(ListBarListStrategy.HOVER | ListBarListStrategy.ROUNDED);
PList pList = new PList(si.getBody(),PList.SINGLE,listStrategy);
pList.setLayoutData(new GridData(GridData.FILL_BOTH));

pList.addMouseListener(new MouseAdapter() {
    public void mouseDown(MouseEvent evt) {
        System.out.println("pList - Mouse Pressed.");
    }
});

System.out.println("Initializing PaletteShelfStrategy GUI.");
PListItem li = new PListItem(pList,SWT.NONE);
li.setText("Example1");
li.setImage(GalleryImageRegistry.getImage(this.getClass(),"list4_small.gif"));

try {
    listener = new Listener() {
        public void handleEvent(Event event) {
            System.out.println("Requesting Example1");
            exampleArea.getDisplay().asyncExec(new Runnable() {
                public void run() {
                    System.out.println("Requesting Example1");
                }
            });
        }
    };

    li.addListener(SWT.MouseUp, listener);
    li.addListener(SWT.MouseDown, listener);
    li.addListener(SWT.Selection, listener);
    li.addListener(SWT.MouseDoubleClick | SWT.MouseHover, listener);
    li.addListener(0, listener);
} catch(Exception exp) {
    exp.printStackTrace();
}
-----------------------------------------------------------------------


_______________________________________________
nebula-dev mailing list
nebula-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/nebula-dev



Back to the top