# Javafx Gestures Touch Input

> Handle JavaFX gestures, pinch-to-zoom, panning, and multi-touch interaction with explicit transform ownership.

- Skill: `johannesrabauer/javafx-gestures-touch-input` (Agent Skill)
- Install (CLI): `npx skillmds@latest add johannesrabauer/javafx-gestures-touch-input`
- Raw SKILL.md: https://api.skillmd.com/api/skills/johannesrabauer/javafx-gestures-touch-input/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: JohannesRabauer (https://skillmd.com/u/johannesrabauer)
- Updated: 2026-09-22
- Page: https://skillmd.com/skills/johannesrabauer/javafx-gestures-touch-input

---


# JavaFX Gestures and Touch Input

Use this skill when the UI needs touch-aware interaction: zoomable viewports, pannable canvases, or
multi-touch surfaces. Libraries such as GestureFX and TuioFX are useful once gestures become central
to the product.

## Example

```java
import javafx.application.ConditionalFeature;
import javafx.application.Platform;
import javafx.scene.image.ImageView;
import javafx.scene.input.ScrollEvent;
import javafx.scene.layout.StackPane;

public class ZoomPane extends StackPane {

    public ZoomPane(ImageView imageView) {
        getChildren().add(imageView);

        addEventFilter(ScrollEvent.SCROLL, event -> {
            if (!event.isControlDown()) {
                return;
            }

            double factor = event.getDeltaY() > 0 ? 1.1 : 0.9;
            imageView.setScaleX(imageView.getScaleX() * factor);
            imageView.setScaleY(imageView.getScaleY() * factor);
            event.consume();
        });

        if (Platform.isSupported(ConditionalFeature.INPUT_TOUCH)) {
            setStyle("-fx-background-color: derive(cornflowerblue, 80%);");
        }
    }
}
```

## Setup notes

- Centralize transform state so zoom, pan, and selection logic do not fight each other.
- Keep pointer, mouse, and touch interactions aligned instead of implementing separate inconsistent behaviors.
- Use library support when gesture orchestration becomes more complex than a single zoomable pane.

## Gotchas

- Gesture input availability varies by hardware and target.
- Coordinate transforms affect hit-testing, overlays, and annotation logic.
- Touch-friendly targets need larger hit areas and clearer feedback than mouse-first UIs.

