Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RangeSlider stutters when the track is dragged in vertical orientation. #1099

Closed
macster110 opened this issue Jan 16, 2019 · 3 comments · Fixed by #1522
Closed

RangeSlider stutters when the track is dragged in vertical orientation. #1099

macster110 opened this issue Jan 16, 2019 · 3 comments · Fixed by #1522
Labels
bug Something isn't working

Comments

@macster110
Copy link

When the RangeSlider track is dragged there is a visible stutter with both the low and high thumbs rapidly moving to other points on the track and then back again. The distance between the low and high thumb can also change. The effect is reduced by dragging the track very slowly. This does not occur when the RangeSlider is horizontal. Tested on the version 8.14.

@HGuillemet
Copy link

I can confirm this, with 11.0.0-SNAPSHOT. For instance when dragging the track upwards, some change events are received with a decreasing value.

@Maxoudela Maxoudela added the bug Something isn't working label Nov 4, 2019
@xupwup
Copy link

xupwup commented Mar 20, 2020

I also have this issue. I've written an ugly workaround for this which resolves the issue. It would be nice if this was fixed properly.

import impl.org.controlsfx.behavior.RangeSliderBehavior;
import impl.org.controlsfx.skin.RangeSliderSkin;
import javafx.application.Platform;
import javafx.scene.layout.StackPane;
import org.controlsfx.control.RangeSlider;

import java.lang.reflect.Field;

/**
 * Fixes https://github.com/controlsfx/controlsfx/issues/1099
 */
public class RangeSliderFix {
	@SuppressWarnings("unchecked")
	private static <T> T get(Object o, String v) throws IllegalAccessException, NoSuchFieldException {
		Field field = o.getClass().getDeclaredField(v);
		field.setAccessible(true);
		return (T) field.get(o);
	}

	static void workAroundRangeSliderBug(RangeSlider rangeSlider) {
		Platform.runLater(() -> {
			try {
				RangeSliderSkin skin = (RangeSliderSkin) rangeSlider.skinProperty().get();
				StackPane rangeBar = get(skin, "rangeBar");
				RangeSliderBehavior rangeSliderBehavior = get(skin, "rangeSliderBehavior");

				double[] preDragPos = new double[1];
				rangeBar.setOnMousePressed(e -> {
					rangeBar.requestFocus();
					preDragPos[0] = -e.getSceneY();
				});

				rangeBar.setOnMouseDragged(e -> {
					double delta = -e.getSceneY() - preDragPos[0];
					rangeSliderBehavior.moveRange(delta);
					preDragPos[0] = -e.getSceneY();
				});
			} catch (NoSuchFieldException | IllegalAccessException e) {
				e.printStackTrace();
			}
		});
	}
}

@james-d
Copy link
Contributor

james-d commented Oct 9, 2023

I inadvertently duplicated this with #1521. I have a proposed fix with PR #1522.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants