[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.platform.swt] Re: Getting Absolute Coordinates of a tree item
|
Sorry about that. You will need to move the mouse:
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.layout.*;
public class EclipseCorner8 {
public static void main (String [] args) {
final Display display = new Display ();
Shell shell = new Shell (display);
shell.setLayout(new FillLayout());
final Tree tree = new Tree (shell, SWT.SINGLE);
for (int i=0; i< 16; i++) {
TreeItem item = new TreeItem (tree, SWT.NULL);
item.setText ("Item " + i);
}
tree.addListener (SWT.Selection, new Listener () {
public void handleEvent (Event event) {
System.out.println("Selection: " + event.item);
}
});
shell.pack();
shell.open();
display.timerExec(1000, new Runnable () {
public void run () {
Rectangle rect = tree.getItem (3).getBounds ();
rect = display.map (tree, null, rect);
Event event = new Event ();
event.type = SWT.MouseMove;
event.x = rect.x;
event.y = rect.y;
display.post (event);
event.type = SWT.MouseDown;
event.button = 1;
display.post (event);
event.type = SWT.MouseUp;
display.post (event);
}
});
while (!shell.isDisposed ()) {
if (!display.readAndDispatch()) display.sleep();
}
display.dispose();
}
}
"Harry" <Harry_sim@xxxxxxxxx> wrote in message
news:05422114eb46eb384702874fe4141a47$1@xxxxxxxxxxxxxxxxxx
> Hi,
>
> I used Display.map only.. I posted my code also in the earlier post...
>
> Mouse is clicked somewhere in the screen not on the first tree item..
>
> Thanks,
> Harry
>