[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
|
- From: Harry_sim@xxxxxxxxx (Harry)
- Date: Wed, 8 Aug 2007 11:11:03 +0000 (UTC)
- Newsgroups: eclipse.platform.swt
- Organization: Eclipse
- User-agent: NewsPortal/0.36 (http://florian-amrhein.de/newsportal)
Hi Tom
I am trying to simulate the Mouse click event on the tree item by getting
the absolute coordinates of the tree item..
Right now I am using tree.getItem[0].getBounds() to get the coordinates of
the tree item relative to the parent....
But I want to convert these coordinates to screen level coordinates so
that I can simulate the mouse event using Display.post().
Display.post method is used to simulate the mouse events....which
requires the absolute screen coordinates where mouse is to be clicked...
So to get the absolute coordinates..display.map is used as follows..
where parent is the composite from CreatePartControl(Composite parent)
method...
final Point point = parent.getDisplay().map(treeViewer.getControl(), null,
new Point(treeViewer.getTree().getItem(0).getBounds().x,
treeViewer.getTree().getItem(0).getBounds().y)) ;
event = new Event();
event.type = SWT.MouseDown;
event.x = point.x;
event.y = point.y;
parent.getDisplay().post(event);
But the mouse is being clicked somewhere not on the first tree item..
Thanks
Harry