cancel
Showing results for 
Search instead for 
Did you mean: 

TouchGFX Scroll Wheel Selected Element during animation

MMess.1
Associate III

Hi all

I want to create a GUI, similar the Scroll Wheel in the provided examples.

MMess1_1-1697119512545.png

The only difference to the Example i need, is that it should always update the Selected value from the scroll wheel. Also when moving around. So I used the scrollWheel.getSelectedItem() which returns the selected item. But as the documentation says:

"Gets selected item. If an animation is in progress, the item that is being scrolled to is returned, not the item that happens to be flying by at the time"

What i actually want is to the the item which is selected also when flying over.

 

Do you have a Idee, how i can get the selected Item also when a animation is in progress?

1 ACCEPTED SOLUTION

Accepted Solutions

Hello @MMess.1 ,

You can implement that by using the 'handleDragEvent' , and 'scrollWheel.getSelectedItem'  functions. Adding the code snippet below to the example will provide your desired functionality. 

void MainView::handleDragEvent(const DragEvent& event)
{
    if (event.getType() == DragEvent::DRAGGED && scrollWheel.isAnimating())
    {
        int centerItem = scrollWheel.getSelectedItem();
        selectedVal.invalidate();
        Unicode::snprintf(selectedValBuffer, SELECTEDVAL_SIZE, "%d", centerItem);
    }

    MainViewBase::handleDragEvent(event);
}

I hope this helps you.

Mohammad MORADI
ST Software Developer | TouchGFX

View solution in original post

1 REPLY 1

Hello @MMess.1 ,

You can implement that by using the 'handleDragEvent' , and 'scrollWheel.getSelectedItem'  functions. Adding the code snippet below to the example will provide your desired functionality. 

void MainView::handleDragEvent(const DragEvent& event)
{
    if (event.getType() == DragEvent::DRAGGED && scrollWheel.isAnimating())
    {
        int centerItem = scrollWheel.getSelectedItem();
        selectedVal.invalidate();
        Unicode::snprintf(selectedValBuffer, SELECTEDVAL_SIZE, "%d", centerItem);
    }

    MainViewBase::handleDragEvent(event);
}

I hope this helps you.

Mohammad MORADI
ST Software Developer | TouchGFX