Hi, so for context I have a horizontal slider I'm using for a simple timeline. I change the value on _Process so increments over time, but the player can also drag it to "rewind".

I'm running a function on the ValueChanged method and I need know if the value was changed from the _Process script or by the player, and I don't know how. I tried using the MouseEntered and MouseExited methods, but they're not reliable because you can drag a slider without actually having your mouse on it (if you start dragging and then move your mouse away).

Any ideas? I'm guessing a more complex input check - check for mouse click on slider, then block the _Process script until mouse is released?
Thanks

  • OK, I did it the way I described and it looks like it's working all right

    timeline.MouseEntered += () => { timelineHovered = true; };
    timeline.MouseExited += () => { timelineHovered = false; };
    public override void _Input(InputEvent _event) {
    	if (_event is InputEventMouseButton mouseEvent) {
    		if (mouseEvent.IsActionPressed("ui_left_click")) {
    			if (timelineHovered) timelineDragged = true;
    		}
    		else if (mouseEvent.IsActionReleased("ui_left_click")) {
    			timelineDragged = false;
    		}
    	}
    }

OK, I did it the way I described and it looks like it's working all right

timeline.MouseEntered += () => { timelineHovered = true; };
timeline.MouseExited += () => { timelineHovered = false; };
public override void _Input(InputEvent _event) {
	if (_event is InputEventMouseButton mouseEvent) {
		if (mouseEvent.IsActionPressed("ui_left_click")) {
			if (timelineHovered) timelineDragged = true;
		}
		else if (mouseEvent.IsActionReleased("ui_left_click")) {
			timelineDragged = false;
		}
	}
}