[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform.swt] Re: Coordinate mapping

You can specify null as the source control to indicate the display coordinates and your control asthe target control. Alternatively, you can use Control.toControl().

You would need to do something like this:
  Point p = display.getCursorLocation();
  Rectangle bounds = myControl.getBounds();
  if (bounds.contains(myControl.toControl(p))) {
     ........
  }

Duong

Jan Kohnert wrote:

Hello List,

I've added a mouse move filter to my display. Inside this filter I receive the current cursor location using Display.

public void handleEvent(Event event) {
  if (event.type == SWT.MouseMove){
    Point p = getDisplay().getCursorLocation();
    ...

Inside my application if've several areas on which I want to check if the mouse if over one of them ot not. That for I get their bounds calling getBounds().

To check if point p is inside a bound I've to map the coordinates. The Display class offers severeal map() functions.

On that point it is unclear for me how I can map the screen coorinate system to the one used by the above descibed areas. the map() functions expects two controls as parameters (beside other paramters). Any idea?

Thanks, Jan