Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Canvas and mouseMoveListener and MacOS
Canvas and mouseMoveListener and MacOS [message #465673] |
Sun, 18 December 2005 16:16 |
Sal Valente Messages: 2 Registered: July 2009 |
Junior Member |
|
|
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++;
}
}
|
|
|
Re: Canvas and mouseMoveListener and MacOS [message #465699 is a reply to message #465673] |
Mon, 19 December 2005 21:54 |
Veronika Irvine Messages: 1272 Registered: July 2009 |
Senior Member |
|
|
The event reported by the OS in this case is kEventMouseDragged and for some
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++;
> }
>
> }
>
|
|
|
Goto Forum:
Current Time: Tue Sep 24 20:11:42 GMT 2024
Powered by FUDForum. Page generated in 0.02563 seconds
|