2023-10-12 07:11 AM
Hi all
I want to create a GUI, similar the Scroll Wheel in the provided examples.
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?
Solved! Go to Solution.
2023-10-24 06:41 AM
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.
2023-10-24 06:41 AM
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.