Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsCanvas and mouseMoveListener and MacOS
https://www.eclipse.org/forums/index.php/mv/msg/147989/465673/#msg_465673
on Windows or Linux.
Here's a program that creates a Table, a Label, and a Canvas, and listens
for MouseMoveEvents from all of them. Select a row in the Table, hold
the mouse button down, and drag it to the label. The program keeps
getting MouseEvents while the mouse moves across the label. Good. But
move it across the Canvas. Neither the Table nor the Canvas will
generate MouseEvents until you release the mouse button.
Is there some way I can get those MouseEvents? Can this be considered a bug
in the MacOS implementation?
Label label = new Label(shell, SWT.BORDER);
label.setText("LABEL");
data = new GridData();
data.grabExcessHorizontalSpace = true;
data.grabExcessVerticalSpace = true;
data.horizontalAlignment = GridData.FILL;
data.verticalAlignment = GridData.FILL;
label.setLayoutData(data);
label.addMouseMoveListener(this);
Canvas canvas = new Canvas(shell, SWT.BORDER);
data = new GridData();
data.grabExcessHorizontalSpace = true;
data.grabExcessVerticalSpace = true;
data.horizontalAlignment = GridData.FILL;
data.verticalAlignment = GridData.FILL;
canvas.setLayoutData(data);
canvas.addMouseMoveListener(this);
shell.open();
}
public void run()
{
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
public void mouseMove(MouseEvent event)
{
System.out.println("" + count);
count++;
}
}]]>Sal Valente2005-12-18T16:16:54-00:00Re: Canvas and mouseMoveListener and MacOS
https://www.eclipse.org/forums/index.php/mv/msg/147989/465699/#msg_465699
reason, SWT is deliberately not sending the MouseMove event for Table (and
all subclasses of Composite).
This sounds like a bug and should be reported against Platform SWT.
"Sal Valente" <svalente@mit.edu> wrote in message
news:pan.2005.12.18.16.16.54.41619@mit.edu...
> This problem is specific SWT on MacOS. It does not seem to be a problem
> on Windows or Linux.
>
> Here's a program that creates a Table, a Label, and a Canvas, and listens
> for MouseMoveEvents from all of them. Select a row in the Table, hold
> the mouse button down, and drag it to the label. The program keeps
> getting MouseEvents while the mouse moves across the label. Good. But
> move it across the Canvas. Neither the Table nor the Canvas will
> generate MouseEvents until you release the mouse button.
>
> Is there some way I can get those MouseEvents? Can this be considered a
> bug
> in the MacOS implementation?
>
> Thanks.
> ----- cut here -----
> import org.eclipse.swt.SWT;
> import org.eclipse.swt.widgets.*;
> import org.eclipse.swt.layout.*;
> import org.eclipse.swt.events.*;
>
> public class MyTable implements MouseMoveListener
> {
> private Display display;
> private Shell shell;
> private int count;
>
> public static void main(String[] argv)
> {
> new MyTable().run();
> }
>
> public MyTable()
> {
> display = new Display();
> shell = new Shell(display);
> shell.setLayout(new GridLayout(2, false));
>
> Table table = new Table(shell, SWT.FULL_SELECTION);
> table.setHeaderVisible(true);
>
> TableColumn column;
> column = new TableColumn(table, SWT.LEFT);
> column.setWidth(120);
> column = new TableColumn(table, SWT.LEFT);
> column.setWidth(120);
>
> TableItem item;
> item = new TableItem(table, 0);
> item.setText(0, "1");
> item.setText(1, "A");
> item = new TableItem(table, 0);
> item.setText(0, "2");
> item.setText(1, "B");
> item = new TableItem(table, 0);
> item.setText(0, "3");
> item.setText(1, "C");
>
> GridData data = new GridData();
> data.grabExcessHorizontalSpace = false;
> data.grabExcessVerticalSpace = true;
> data.horizontalAlignment = GridData.FILL;
> data.verticalAlignment = GridData.FILL;
> data.verticalSpan = 2;
> table.setLayoutData(data);
> table.addMouseMoveListener(this);
>
> Label label = new Label(shell, SWT.BORDER);
> label.setText("LABEL");
> data = new GridData();
> data.grabExcessHorizontalSpace = true;
> data.grabExcessVerticalSpace = true;
> data.horizontalAlignment = GridData.FILL;
> data.verticalAlignment = GridData.FILL;
> label.setLayoutData(data);
> label.addMouseMoveListener(this);
>
> Canvas canvas = new Canvas(shell, SWT.BORDER);
> data = new GridData();
> data.grabExcessHorizontalSpace = true;
> data.grabExcessVerticalSpace = true;
> data.horizontalAlignment = GridData.FILL;
> data.verticalAlignment = GridData.FILL;
> canvas.setLayoutData(data);
> canvas.addMouseMoveListener(this);
>
> shell.open();
> }
>
> public void run()
> {
> while (!shell.isDisposed()) {
> if (!display.readAndDispatch())
> display.sleep();
> }
> display.dispose();
> }
>
> public void mouseMove(MouseEvent event)
> {
> System.out.println("" + count);
> count++;
> }
>
> }
>]]>Veronika Irvine2005-12-19T21:54:30-00:00