2019-02-14 06:29 AM
When requiring a virtual function for a slider on value change / start / confirmed (touchgfx 4.10),
the code generated is broken.
The callback that calls the cvirtual function contains a comparison between a touchgfx::Slider* and a int*
if (&src == &value) {
virtual_function();
}
if changed with something with a little more sense, like:
if (src.getValue() == value) {
vierual_function()
}
the error is a discarded qualifiers. This error is raised because the Slider getValue method is not declared as const and the callback gets as input a const touchgfx::Slider. So the method should be:
int getValue() const {
return current_value;
}
Am I right?
2019-02-14 11:30 PM
Hi @MRagn,
No, i don't think you're correct here, if i understand your problem correctly. Here's the generated code for a callback handler that calls a virtual function (specificed by the slideradjustmentconfirmed interaction - I specified to call a new virtual function myfunc):
void Screen1ViewBase::sliderValueConfirmedCallbackHandler(const touchgfx::Slider& src, int value)
{
if (&src == &slider1)
{
//Interaction1
//When slider1 value confirmed call virtual function
//Call myfunc
myfunc(value);
}
}
In this case, value isn't even considered when checking the source of the callback. The reference to the slider object is to determine where the callback came from (in order to have one handler for a single type). And the value is passed to myFunc() that has the following auto-generated definition:
/*
* Custom Action Handlers
*/
virtual void myfunc(int value)
{
// Override and implement this function in Screen1View
}
Am i understanding your problem correctly?
2019-02-14 11:34 PM
And it's the same for all available interactions for the Slider:
void Screen1ViewBase::sliderValueStartedChangeCallbackHandler(const touchgfx::Slider& src, int value)
{
if (&src == &slider1)
{
//Interaction2
//When slider1 slider adjustment initiated call virtual function
//Call myfunc2
myfunc2(value);
}
}
void Screen1ViewBase::sliderValueChangedCallbackHandler(const touchgfx::Slider& src, int value)
{
if (&src == &slider1)
{
//Interaction3
//When slider1 value changed call virtual function
//Call myfunc3
myfunc3(value);
}
}
void Screen1ViewBase::sliderValueConfirmedCallbackHandler(const touchgfx::Slider& src, int value)
{
if (&src == &slider1)
{
//Interaction1
//When slider1 value confirmed call virtual function
//Call myfunc
myfunc(value);
}
}