I try to use the addmouselistener method of the form and check if the clicks are in the area of the title bar, but the mouse listener is not working. I tried to add the mouse listener on form and on form.getform() and on form.getBody() neither one works.
Here is the code where I am creating the form and trying to add a mouse listener on it:
toolKit = new FormToolkit(parent.getDisplay());
form = toolKit.createScrolledForm(parent);
FillLayout layout = new FillLayout();
layout.type = SWT.VERTICAL;
layout.marginHeight = 10;
layout.marginWidth = 4;
canvas = new FigureCanvas(form.getBody(), SWT.DOUBLE_BUFFERED );
canvas.setViewport(new FreeformViewport());
canvas.setBackground(ColorConstants.white);
canvas.setContents(root);
form.getBody().setLayout(layout);
form.setText("Data Transactions View");
createHeaderRegion(form);
toolKit.decorateFormHeading(form.getForm());
form.getToolBarManager().add(new Action("This") { });
form.getForm().addMouseListener(new MouseListener(){
@Override
public void mouseDoubleClick(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mouseDown(MouseEvent e) {
if(e.x<10 && e.y<10){
form.getToolBarManager().add(new Action("This is the toolbar") { }); // NEW LINE
form.getToolBarManager().update(true); // NEW LINE
}
}
@Override
public void mouseUp(MouseEvent e) {
// TODO Auto-generated method stub
}
}});
Any suggestions?
You have to add the Listener to the head of the Form.