use of org.malai.javafx.interaction.library.KeysScroll in project Malai by arnobl.
the class BasicZoomer method configureBindings.
@Override
protected void configureBindings() {
if (withKeys) {
nodeBinder(Zoom.class, new KeyPressed(false)).on(zoomable).first((c, i) -> {
final String key = i.getKey();
c.setZoomable(getZoomable());
if ("+".equals(key)) {
c.setZoomLevel(zoomable.getZoom() + zoomable.getZoomIncrement());
} else {
c.setZoomLevel(zoomable.getZoom() - zoomable.getZoomIncrement());
}
c.setPx(-1d);
c.setPy(-1d);
}).when(i -> "+".equals(i.getKey()) || "-".equals(i.getKey())).bind();
}
nodeBinder(Zoom.class, new KeysScroll()).on(zoomable).first(c -> c.setZoomable(zoomable)).then((c, i) -> {
c.setZoomLevel(zoomable.getZoom() + (i.getScrollData().getIncrement() > 0 ? zoomable.getZoomIncrement() : -zoomable.getZoomIncrement()));
c.setPx(i.getScrollData().getPx());
c.setPy(i.getScrollData().getPy());
}).when(i -> i.getKeys().size() == 1 && i.getKeyCodes().get(0) == KeyCode.CONTROL).bind();
}
Aggregations