[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
|
Investigate Display.map().
"Harry" <Harry_sim@xxxxxxxxx> wrote in message
news:c053e31ca59126486ad867033bc1e8ad$1@xxxxxxxxxxxxxxxxxx
> 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
>
>