I am capturing mouse events inside of a shell with Composites by adding a Filter.
For now the events are positioned relative to the Composites, where they occure.
How can I retrieve MouseEvents absolute position?
(Absolute position is the position with 0,0 in the left uper corner of the display).
parentShell.getDisplay().addFilter(SWT.MouseDown, new Listener() {
@Override
public void handleEvent(Event event) {
//do not know the absolute position here
}
});
You can use
Control#toDisplay(int, int)to convert any relative coordinates to display relative absolute values.The above will work if the event you received is a mouse event, which it is in your example. You can also use
Display#getCursorLocation()at any point to get absolute mouse location if you do not have a mouse event at hand.