Java Code Examples for javafx.scene.input.ScrollEvent#isControlDown()

The following examples show how to use javafx.scene.input.ScrollEvent#isControlDown() . 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: PlotCanvasBase.java    From phoebus with Eclipse Public License 1.0 6 votes vote down vote up
/** Zoom in/out triggered by mouse wheel
 *  @param event Scroll event
 */
protected void wheelZoom(final ScrollEvent event)
{
    // Invoked by mouse scroll wheel.
    // Only allow zoom (with control), not pan.
    if (! event.isControlDown())
        return;

    if (event.getDeltaY() > 0)
        zoomInOut(event.getX(), event.getY(), 1.0/ZOOM_FACTOR);
    else if (event.getDeltaY() < 0)
        zoomInOut(event.getX(), event.getY(), ZOOM_FACTOR);
    else
        return;
    event.consume();
}
 
Example 2
Source File: WebViewEventDispatcher.java    From oim-fx with MIT License 5 votes vote down vote up
private void processScrollEvent(ScrollEvent ev) {
    if (page == null) {
        return;
    }
    double dx = - ev.getDeltaX() * webView.getFontScale() * webView.getScaleX();
    double dy = - ev.getDeltaY() * webView.getFontScale() * webView.getScaleY();
    WCMouseWheelEvent wheelEvent =
            new WCMouseWheelEvent((int)ev.getX(), (int)ev.getY(),
                (int)ev.getScreenX(), (int)ev.getScreenY(),
                System.currentTimeMillis(),
                ev.isShiftDown(), ev.isControlDown(), ev.isAltDown(),
                ev.isMetaDown(), (float)dx, (float)dy);
    page.dispatchMouseWheelEvent(wheelEvent);
    ev.consume();
}
 
Example 3
Source File: JFXZoomListenerManager.java    From tuxguitar with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void handle(ScrollEvent event) {
	if(!this.control.isIgnoreEvents()) {
		if( event.isControlDown() ) {
			this.onZoom(new UIZoomEvent(this.control, (event.getDeltaY() > 0 ? 1 : -1)));
			
			event.consume();
		}
	}
}
 
Example 4
Source File: PanOrZoomOnScrollHandler.java    From gef with Eclipse Public License 2.0 3 votes vote down vote up
/**
 * Returns <code>true</code> if the given {@link ScrollEvent} should trigger
 * panning. Otherwise returns <code>false</code>.
 *
 * @param event
 *            The {@link ScrollEvent} in question.
 * @return <code>true</code> to indicate that the given {@link ScrollEvent}
 *         should trigger panning, otherwise <code>false</code>.
 */
protected boolean isPan(ScrollEvent event) {
	// Do not scroll when a modifier key (<Alt>, <Control>, <Meta>) is
	// pressed.
	return !(event.isAltDown() || event.isControlDown()
			|| event.isMetaDown());
}
 
Example 5
Source File: PanOrZoomOnScrollHandler.java    From gef with Eclipse Public License 2.0 2 votes vote down vote up
/**
 * Returns <code>true</code> if the given {@link ScrollEvent} should trigger
 * zooming. Otherwise returns <code>false</code>. Per default, either
 * <code>&lt;Control&gt;</code> or <code>&lt;Alt&gt;</code> has to be
 * pressed so that <code>true</code> is returned.
 *
 * @param event
 *            The {@link ScrollEvent} in question.
 * @return <code>true</code> if the given {@link ScrollEvent} should trigger
 *         zooming, otherwise <code>false</code>.
 */
protected boolean isZoom(ScrollEvent event) {
	return event.isControlDown() || event.isAltDown();
}