2019-10-15 11:34 PM
Hi @Martin KJELDSEN !
I'm working on a slider and I have two questions for you. =)
sliderValueText.moveTo(sliderBar.getIndicatorX(), SLIDER_TEXT_POS_Y);
//Interaction1
//When slider1 value changed move sliderValueText
//Set position x:71 and y:71 on sliderValueText
sliderValueText.moveTo(281,71);
But as you can see, the comment is not correct the x-position should be 281 and not 71. Just a minor thing I came across while testing in the designer.
Superthankful as always for help!
2019-10-17 12:42 AM
Hi Sandy,
Re: your bug, could you try this in the latest release 4.12.3 before we go any further with that?
Re your feature request. This method allows you to associate a callback with a handler that will be called whenever the value of the slider changes. You could use that value to move your text area along with it. Notice that here you're getting the "value" and not the x coordinate, so you'll have to calculate it.
/**
* @fn void Slider::setNewValueCallback(GenericCallback< const Slider&, int >& callback)
*
* @brief Associates an action to be performed when the slider changes its value.
*
* Associates an action to be performed when the slider changes its value.
*
* @param callback The callback to be executed. The callback will be given a reference to
* the Slider and the current value of the slider.
*
* @see GenericCallback
*/
void setNewValueCallback(GenericCallback< const Slider&, int >& callback)
{
newValueCallback = &callback;
}
If you want to embed this feature inside your custom Slider, then simply implement your change in:
void Slider::updateIndicatorPosition(int16_t position)
{
...
// Communicate the new value if a listener is registered
if ((newValueCallback != 0) && newValueCallback->isValid())
{
newValueCallback->execute(*this, currentValue);
}
}
You'll see at the bottom there's some code to execute the callback imentioned before with the currentValue. Somewhere in this method, you'll move your textarea to follow the "x position" (For HORIZONTAL) and not the currentValue which relates to the actual value range defined by the user.
It should be apparent from the source code of the Slider how to get the x position.
/Martin
2019-10-17 05:25 AM
Hi!
Thank you for the answers. :)
I tried generating code in the latest release (4.12.3) of the designer and the issue is still there unfortunately. The comment is still wrong. This is not an issue really, just thought I should share it with you.
Regarding the feature I was hoping it was already implemented. I'll try calculating something of my own. :)
Kind regards
Sandy