Java Code Examples for org.eclipse.swt.SWT#MouseExit

The following examples show how to use org.eclipse.swt.SWT#MouseExit . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SWTSkin.java    From BiglyBT with GNU General Public License v2.0 6 votes vote down vote up
protected static Listener getHandCursorListener(Display display) {
	if (handCursorListener == null) {
		handCursor = new Cursor(display, SWT.CURSOR_HAND);
		handCursorListener = new Listener() {
			@Override
			public void handleEvent(Event event) {
				if (event.type == SWT.MouseEnter) {
					((Control) event.widget).setCursor(handCursor);
				}
				if (event.type == SWT.MouseExit) {
					((Control) event.widget).setCursor(null);
				}
			}
		};
	}

	return handCursorListener;
}
 
Example 2
Source File: Utils.java    From BiglyBT with GNU General Public License v2.0 5 votes vote down vote up
public static void addSafeMouseUpListener(Control control, Listener mouseDownListener,
		Listener mouseUpListener) {
	Listener l = new Listener() {
		boolean isMouseDown = false;

		@Override
		public void handleEvent(Event e) {
			switch (e.type) {
				case SWT.MouseDown:
					isMouseDown = true;
					if (mouseDownListener != null) {
						mouseDownListener.handleEvent(e);
					}
					break;
				case SWT.MouseExit:
					isMouseDown = false;
					break;
				case SWT.MouseUp:
					if (!isMouseDown) {
						return;
					}
					if (e.widget instanceof Control) {
						Point size = ((Control) e.widget).getSize();
						Rectangle bounds = new Rectangle(0, 0, size.x, size.y);
						
						if (!bounds.contains(e.x, e.y)) {
							return;
						}
					}
					mouseUpListener.handleEvent(e);
					break;
			}
		}
	};
	control.addListener(SWT.MouseDown, l);
	control.addListener(SWT.MouseUp, l);
	control.addListener(SWT.MouseExit, l);
}
 
Example 3
Source File: Java2DDisplaySurface.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void dispatchMouseEvent(final int swtMouseEvent) {
	final int x = mousePosition.x;
	final int y = mousePosition.y;
	for (final IEventLayerListener gl : listeners) {
		switch (swtMouseEvent) {
			case SWT.MouseDown:
				gl.mouseDown(x, y, 1);
				break;
			case SWT.MouseUp:
				gl.mouseUp(x, y, 1);
				break;
			case SWT.MouseMove:
				gl.mouseMove(x, y);
				break;
			case SWT.MouseEnter:
				gl.mouseEnter(x, y);
				break;
			case SWT.MouseExit:
				gl.mouseExit(x, y);
				break;
			case SWT.MenuDetect:
				gl.mouseMenu(x, y);
				break;
		}
	}
}
 
Example 4
Source File: FlatButton.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void handleEvent(final Event e) {
	switch (e.type) {
		case SWT.MouseExit:
			doHover(false);
			break;
		case SWT.MouseMove:
			break;
		case SWT.MouseEnter:
		case SWT.MouseHover:
			doHover(true);
			e.doit = true;
			break;
		case SWT.MouseUp:
			if (e.button == 1 && getClientArea().contains(e.x, e.y)) {
				doButtonUp();
			}
			break;
		case SWT.MouseDown:
			if (e.button == 1 && getClientArea().contains(e.x, e.y)) {
				doButtonDown();
			}
			break;
		default:
			;
	}
}
 
Example 5
Source File: SWTOpenGLDisplaySurface.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void dispatchMouseEvent(final int swtMouseEvent) {
	final GamaPoint p = renderer.getCameraHelper().getMousePosition();
	final int x = (int) p.x;
	final int y = (int) p.y;
	for (final IEventLayerListener gl : listeners) {
		switch (swtMouseEvent) {
			case SWT.MouseDown:
				gl.mouseDown(x, y, 1);
				break;
			case SWT.MouseUp:
				gl.mouseUp(x, y, 1);
				break;
			case SWT.MouseMove:
				gl.mouseMove(x, y);
				break;
			case SWT.MouseEnter:
				gl.mouseEnter(x, y);
				break;
			case SWT.MouseExit:
				gl.mouseExit(x, y);
				break;
			case SWT.MenuDetect:
				gl.mouseMenu(x, y);
				break;
		}
	}
}
 
Example 6
Source File: InformationPresenterControlManager.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void handleEvent(Event event) {
    switch (event.type) {
        case SWT.Activate:
        case SWT.MouseVerticalWheel:
        case SWT.MouseUp:
        case SWT.MouseDown:
        case SWT.FocusOut:
            IInformationControl iControl = fInformationControl;
            if (iControl != null && !iControl.isFocusControl()) {
                hideInformationControl();
            }
            break;

        case SWT.MouseMove:
        case SWT.MouseEnter:
        case SWT.MouseExit:
            handleMouseMove(event);
            break;

        case SWT.KeyDown:
            if (event.keyCode == SWT.ESC) {
                hideInformationControl();

            } else if (fActivateEditorBinding != null
                    && KeyBindingHelper.matchesKeybinding(event.keyCode, event.stateMask,
                            fActivateEditorBinding)) {
                hideInformationControl(true, true);
            }
            break;
    }
}