I’m using the same observer for multiple sliders, and I want to obtain the specific slider control being changed from the onValueChangedObservable.
This time, I’m using a slider (whereas here is the same issue I posted a year ago about ColorPicker).
I think the change required is in one place for slider, and one place for color picker:
line 160 in baseSlider:
this.onValueChangedObservable.notifyObservers(this._value);
And line 90 in colorpicker.ts:
this.onValueChangedObservable.notifyObservers(this._value);
Recommend to change those lines to:
this.onValueChangedObservable.notifyObservers(this._value, -1, this, this);
Background
from Babylon.js docs
notifyObservers(
eventData: T,
mask?: number,
target?: any,
currentTarget?: any,
userInfo?: any,
): boolean
Both target and currentTarget are defined as Control.
Looking at pointer observables, target comes from a parameter to the calling function, but currentTarget is “this”: the control from which the observable is called. In the Button Control, target and currentTarget are identical in my simple usage/experiments.
For JavaScript Events in general, here is the difference between target and currentTarget (from sqlpey.com):
- target: The target property refers to the element that dispatched the event. For instance, if a user clicks on a child <button> element within a <div>, the target will be the button itself. This property is helpful for determining exactly which element triggered the event.
- currentTarget: Conversely, the currentTarget property represents the element to which the event listener is currently attached. Continuing with the previous example, if the <div> has an event listener for the click event, the currentTarget will be the <div> no matter which button is clicked.
From this description and because the “event listener” (aka observable) is on the slider itself, both target and currentTarget should probably be the same in the case of these slider and colorpicker modifications.

